#include <EEPROM.h>
#include <Wire.h>
int voltage_p=A0;
int current_p=A1;
int pressure_p=A2;
double v,p,psi;
void setup() {
// put your setup code here, to run once:
Serial.begin(2000);
pinMode(voltage_p, INPUT);
pinMode(current_p, INPUT);
pinMode(pressure_p, INPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(2, OUTPUT);
EEPROM.write(0,80);//kw
EEPROM.write(1,60);//V
EEPROM.write(2,20);//psi
delay(500);
p=EEPROM.read(0);
v=EEPROM.read(1);psi=EEPROM.read(2);
Serial.println(p);
Serial.println(v); Serial.println(psi);
}
void loop() {
// put your main code here, to run repeatedly:
double v1=analogRead(voltage_p)*5/1023;
//here psi1 is not found hence the voltage from arduino is used as an anology for the value of psi1
double psi1=analogRead(pressure_p)*5/1023;
//assuming relay is in normally closed mode(com,nc are connected to the device)
double p1=v1*v1/10;//the p1(power)is found by assuming a resistor is in place.
if(p1>p)
{
digitalWrite(3,HIGH);
}
else
digitalWrite(3, LOW);
delay(50);
if(v1>v)//LED
{
digitalWrite(2, HIGH);
}
else
digitalWrite(2, LOW);
delay(50);
if(psi1<psi)//the deviced used for this is a buzzer
{
digitalWrite(4, HIGH);
}
else
digitalWrite(4, LOW);
delay(1000);
Serial.println(p1); Serial.println(v1); Serial.println(psi1);
}