Thursday, October 13, 2016

Voltage Reader with Arduino

Voltage Reader with Arduino


#define buzz 3
int ldrPin=0;
#include <LiquidCrystal.h>
#define D4 6
#define D5 7
#define D6 8
#define D7 9
#define RS 11
#define EN 12
LiquidCrystal lcd(12, 11, 6, 7, 8, 9);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(buzz, OUTPUT);
}

void loop()
{
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.print(voltage);
Serial.println(" volts");
if (voltage<=8)
{
  digitalWrite(buzz, HIGH);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("MAX VOLTAGE:12");
  lcd.setCursor(0,1);
  lcd.print("PST VOLTAGE:");
  lcd.setCursor(13,1);
  lcd.print(voltage);
}
  else {
  digitalWrite(buzz, LOW);

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("MAX VOLTAGE:12");
  lcd.setCursor(0,1);
  lcd.print("PST VOLTAGE:");
  lcd.setCursor(13,1);
  lcd.print(voltage);
}}

Available link for download