Skip to content

Instantly share code, notes, and snippets.

@elktros
Created September 30, 2016 11:00
Show Gist options
  • Save elktros/6383807ec979ac990f2b89560f388505 to your computer and use it in GitHub Desktop.
Save elktros/6383807ec979ac990f2b89560f388505 to your computer and use it in GitHub Desktop.
#include "LiquidCrystal.h"
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
float voltage = 0.0;
float temp=0.0;
int analog_value;
void setup()
{
lcd.begin(16, 2);
lcd.setCursor (0,0);
lcd.print(" Arduino based ");
lcd.setCursor(0,1);
lcd.print("Digital Voltmeter");
delay(2000);
}
void loop()
{
analog_value = analogRead(A0);
voltage = (analog_value * 5.0) / 1024.0;
if (voltage < 0.1)
{
voltage=0.0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Voltage= ");
lcd.print(voltage);
lcd.setCursor(13,1);
lcd.print("V");
delay(30);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment