Professional Documents
Culture Documents
void setup() {
lcd.begin();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.clear();
lcd.print("Arduino");
lcd.setCursor(0, 1);
lcd.print("Voltmeter");
delay(1500);
lcd.clear();
lcd.print("By - The ");
lcd.setCursor(0, 1);
lcd.print("IoT Projects");
delay(2000);
lcd.clear();
pinMode(A0, INPUT);
Serial.begin(9600); // starting the Serial Monitor
}
void loop() {
input = analogRead(A0); //analogRead function is used to
recive analog data
vol = (input * 9.0) / 1024.0; //formula using for perform action
lcd.print("voltage is:");
lcd.setCursor(0, 1);
delay(100);
lcd.print(vol);
delay(1000);
lcd.clear();
}Lesson 6. Making a Voltmeter with Serial Monitor float r1 = 1000000; //1000 kOhm resistor [change this if used a
different resistor value]
float r2 = 100000; //10 kOhm resister [change this if used a
Components different resistor value]<br>
1 Arduino Uno board
1 USB data cable void setup() {
Several jumper wires Serial.begin(9600); //speed = 9600
1 resistor ( 1K Ω)
1 resistor (10 K Ω) // 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("");
void loop() {
float v = (analogRead(0) * vPow) / 1024.0; //when reading
analog values, divide by 1024
float v2 = v / (r2 / (r1 + r2));