Skip to content

Instantly share code, notes, and snippets.

@hisachin
Last active February 6, 2016 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisachin/9967a7b8b15466e203b9 to your computer and use it in GitHub Desktop.
Save hisachin/9967a7b8b15466e203b9 to your computer and use it in GitHub Desktop.
/*
PROJECTSDUNIA
" DC Votmeter using ARDUINO "
Designed By Sachin Jaiswal
In this we measure the input voltage and display it on the 16 * 2 LCD Module
For Full Description Visit http://projectsdunia.blogspot.com
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins
float vin=0.0;
float temp=0.0;
float r1=100000.0; // Set the value of resister R1
float r2=10000.0; // Set the value of resister R2
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.print("PROJECTSDUNIA"); // Print a message to the LCD.
delay(1000);
lcd.clear();
lcd.print("DC VoltMeter");
}
void loop() {
int analog_val=analogRead(A0); // read the value of analog pin A0 and store it in the variable analog_val
temp = (analog_val * 5.0)/1024.0;
vin = temp/(r2/(r1+r2));
if(vin<0.1)
{
vin=0.0;
}
lcd.setCursor(0, 1); // set the cursor to column 0 line 1
lcd.print("Voltage = "); // print the voltage
lcd.println(vin);
delay(300);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment