Variac Voltage and Current Monitor
 Set for a 16x2 LCD display.   
  The circuit:
 * LCD RS pin to digital pin 7
 * LCD Enable pin to digital pin 6
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 
   */
// include the library code:
#include <LiquidCrystal.h>
//#include <OneWire.h>
//#include <DallasTemperature.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
//const int busPin = 10;
//OneWire bus(busPin);
//DallasTemperature sensors (&bus);
//DeviceAddress sensor;

int voltage=A0; // select the input pin for the voltage sensor
int current1=A1; // select the input pin for the current sensor #1
int voltageValue = 0; // variable to store the value coming from the voltage sensor
int current1Value = 0; // variable to store the value coming from the current sensor #1
float curtrip = 3.00;
int ledPin = 9;
int relayPin = 8;
void setup() {
 //  pinMode(busPin, INPUT);
 //  sensors.begin();
//  sensors.getAddress(sensor, 0);
   pinMode(ledPin, OUTPUT);
  pinMode(relayPin, OUTPUT);
  // set up the LCD's number of columns and rows: 
  lcd.begin(24, 2);  // initialize the lcd
  lcd.clear();  // clear lcd
  lcd.setCursor(3,0);
  lcd.print("TDA LLC");
  lcd.setCursor(1,1);
  lcd.print("Variac Monitor");
 
  digitalWrite(ledPin, LOW);
  digitalWrite (relayPin, LOW);
  
  delay(3000);
  
 }
   void loop() {
    //  sensors.requestTemperatures();
    //  float tempF = sensors.getTempF(sensor);
     voltageValue = analogRead(voltage); 
  current1Value = analogRead(current1);
  float vol = (voltageValue * (5.00/1023.0))*120;
  float cur1 = current1Value * (5.00/1023.0);
   // set the cursor to column 0, line 0
    if (cur1 < curtrip){
   digitalWrite(ledPin, LOW);
  digitalWrite (relayPin, HIGH);
  lcd.clear();
  // read and display the voltage
  lcd.setCursor(0,0);
  lcd.print("Vol=");
  lcd.setCursor(5,0);
  lcd.print(vol);
  
 // lcd.setCursor(13,0);
 // lcd.print("Temp=");
 // lcd.setCursor(19,0);
 // lcd.print(tempF);
   
  // read and display the current
  lcd.setCursor(0, 1);
  lcd.print("Cur=");
  lcd.setCursor(7, 1);
  lcd.print(cur1);
  delay(500);
  }
  else{
     while(1){
       digitalWrite(ledPin, HIGH);
       digitalWrite(relayPin, LOW);
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Tripped Over Cur");
     lcd.setCursor(0,1);
     lcd.print("Press Reset");
     delay(1000);
     }
  }
      
  }  
      
