Components and supplies
Resistor 10k ohm
Resistor 100k ohm
Rotary potentiometer (generic)
Jumper wires (generic)
Arduino UNO
Through Hole Resistor, 120 ohm
Solderless Breadboard Half Size
Tools and machines
Soldering iron (generic)
Solder Wire, Lead Free
Mastech MS8217 Autorange Digital Multimeter
Project description
Code
Arduino Voltmeter
arduino
Arduino code for voltmeter
1#include <LiquidCrystal.h> 2 3/* 4 LiquidCrystal Library - Hello World 5 6 Demonstrates the use a 16x2 LCD display. The LiquidCrystal 7 library works with all LCD displays that are compatible with the 8 Hitachi HD44780 driver. There are many of them out there, and you 9 can usually tell them by the 16-pin interface. 10 11 This sketch prints "Hello World!" to the LCD 12 and shows the time. 13 14 The circuit: 15 * LCD RS pin to digital pin 12 16 * LCD Enable pin to digital pin 11 17 * LCD D4 pin to digital pin 5 18 * LCD D5 pin to digital pin 4 19 * LCD D6 pin to digital pin 3 20 * LCD D7 pin to digital pin 2 21 * LCD R/W pin to ground 22 * LCD VSS pin to ground 23 * LCD VCC pin to 5V 24 * 10K resistor: 25 * ends to +5V and ground 26 * wiper to LCD VO pin (pin 3) 27 28 Library originally added 18 Apr 2008 29 by David A. Mellis 30 library modified 5 Jul 2009 31 by Limor Fried (http://www.ladyada.net) 32 example added 9 Jul 2009 33 by Tom Igoe 34 modified 22 Nov 2010 35 by Tom Igoe 36 modified 7 Nov 2016 37 by Arturo Guadalupi 38 39 This example code is in the public domain. 40 41 http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld 42 43 Modified by : BMIAK Basnayaka for SETNFIX 44 Date : 22/04/2021 45 http://setnfix.com 46 47*/ 48 49// include the library code: 50#include <LiquidCrystal.h> 51 52// initialize the library by associating any needed LCD interface pin 53// with the arduino pin number it is connected to 54const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 55LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 56int analogInput = 0; 57float vout = 0.0; 58float vin = 0.0; 59float R1 = 100000.0; // resistance of R1 (100K) -see text! 60float R2 = 10000.0; // resistance of R2 (10K) - see text! 61int value = 0; 62 63void setup() { 64 // set up the LCD's number of columns and rows: 65 lcd.begin(16, 2); 66 // Print a message to the LCD. 67 68 lcd.print("SetNFix"); 69 pinMode(analogInput, INPUT); 70Serial.begin(9600); 71 delay(5000); 72} 73 74void loop() { 75 76 // read the value at analog input 77 value = analogRead(analogInput); 78 vout = (value * 5.0) / 1024.0; // see text 79 vin = vout / (R2/(R1+R2)); 80 if (vin<0.09) { 81 vin=0.0;//statement to quash undesired reading ! 82} 83 // set the cursor to column 0, line 1 84 // (note: line 1 is the second row, since counting begins with 0): 85 lcd.setCursor(0, 0); 86 lcd.print("Volt Meter"); 87 lcd.setCursor(0, 1); 88 // print the number of seconds since reset: 89 unsigned int len = sizeof(vin); 90 len = len +2; 91 92 lcd.print(vin); 93 lcd.print(" "); 94 //lcd.setCursor(len, 1); 95 lcd.print("Volts"); 96 lcd.print(" "); 97} 98
Arduino Voltmeter
arduino
Arduino code for voltmeter
1#include <LiquidCrystal.h> 2 3/* 4 LiquidCrystal Library - Hello World 5 6 Demonstrates the use a 16x2 LCD display. The LiquidCrystal 7 library works with all LCD displays that are compatible with the 8 Hitachi HD44780 driver. There are many of them out there, and you 9 can usually tell them by the 16-pin interface. 10 11 This sketch prints "Hello World!" to the LCD 12 and shows the time. 13 14 The circuit: 15 * LCD RS pin to digital pin 12 16 * LCD Enable pin to digital pin 11 17 * LCD D4 pin to digital pin 5 18 * LCD D5 pin to digital pin 4 19 * LCD D6 pin to digital pin 3 20 * LCD D7 pin to digital pin 2 21 * LCD R/W pin to ground 22 * LCD VSS pin to ground 23 * LCD VCC pin to 5V 24 * 10K resistor: 25 * ends to +5V and ground 26 * wiper to LCD VO pin (pin 3) 27 28 Library originally added 18 Apr 2008 29 by David A. Mellis 30 library modified 5 Jul 2009 31 by Limor Fried (http://www.ladyada.net) 32 example added 9 Jul 2009 33 by Tom Igoe 34 modified 22 Nov 2010 35 by Tom Igoe 36 modified 7 Nov 2016 37 by Arturo Guadalupi 38 39 This example code is in the public domain. 40 41 http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld 42 43 Modified by : BMIAK Basnayaka for SETNFIX 44 Date : 22/04/2021 45 http://setnfix.com 46 47*/ 48 49// include the library code: 50#include <LiquidCrystal.h> 51 52// initialize the library by associating any needed LCD interface pin 53// with the arduino pin number it is connected to 54const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 55LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 56int analogInput = 0; 57float vout = 0.0; 58float vin = 0.0; 59float R1 = 100000.0; // resistance of R1 (100K) -see text! 60float R2 = 10000.0; // resistance of R2 (10K) - see text! 61int value = 0; 62 63void setup() { 64 // set up the LCD's number of columns and rows: 65 lcd.begin(16, 2); 66 // Print a message to the LCD. 67 68 lcd.print("SetNFix"); 69 pinMode(analogInput, INPUT); 70Serial.begin(9600); 71 delay(5000); 72} 73 74void loop() { 75 76 // read the value at analog input 77 value = analogRead(analogInput); 78 vout = (value * 5.0) / 1024.0; // see text 79 vin = vout / (R2/(R1+R2)); 80 if (vin<0.09) { 81 vin=0.0;//statement to quash undesired reading ! 82} 83 // set the cursor to column 0, line 1 84 // (note: line 1 is the second row, since counting begins with 0): 85 lcd.setCursor(0, 0); 86 lcd.print("Volt Meter"); 87 lcd.setCursor(0, 1); 88 // print the number of seconds since reset: 89 unsigned int len = sizeof(vin); 90 len = len +2; 91 92 lcd.print(vin); 93 lcd.print(" "); 94 //lcd.setCursor(len, 1); 95 lcd.print("Volts"); 96 lcd.print(" "); 97} 98
Downloadable files
Circuit
There are two diagrams
Circuit
Comments
Only logged in users can leave comments