first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
/*
*
* Udemy.com
* Building an Arduino DC Voltmeter
*
*/
float vPow = 4.7;
float r1 = 68000;
float r2 = 680000;
int speed = 120;
void setup() {
pinMode(3, OUTPUT);
analogWrite(3, speed);
Serial.begin(9600);
// Send ANSI terminal codes
Serial.print("\x1B");
Serial.print("[2J");
Serial.print("\x1B");
Serial.println("[H");
// End ANSI terminal codes
Serial.println("--------------------");
Serial.println("DC VOLTMETER");
Serial.print("Maximum Voltage: ");
Serial.print((int)(vPow / (r2 / (r1 + r2))));
Serial.println("V");
Serial.println("--------------------");
Serial.println("");
delay(2000);
}
void loop() {
float v = (analogRead(A0)* vPow) / 1024.0;
float v2 = v / (r2 / (r1 + r2));
// Send ANSI terminal codes
//Serial.print("\x1B");
//Serial.print("[1A ");
// End ANSI terminal codes
Serial.print(analogRead(A0));
Serial.print(" ");
Serial.println(v2);
// First we check to see if incoming data is available:
while (Serial.available() > 0)
{
// If it is, we'll use parseInt() to pull out any numbers:
speed = Serial.parseInt();
// Because analogWrite() only works with numbers from
// 0 to 255, we'll be sure the input is in that range:
speed = constrain(speed, 0, 255);
// We'll print out a message to let you know that the
// number was received:
Serial.print("Setting speed to ");
Serial.println(speed);
// And finally, we'll set the speed of the motor!
analogWrite(3, speed);
}
}