int v2=A3;
int why;
float v1;
int led =9;
void setup() {
// put your setup code here, to run once:
pinMode (v2,INPUT);
pinMode (led,OUTPUT );
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
why=analogRead(v2);
v1=(5./1023.)*why;// used to convert 1023 into 5 volts as A3 returns value between0 to 1023
Serial.println(v1);
delay(1000);
if(v1>4. && v1<=5.){
Serial.println(" this is too high voltage ");
digitalWrite(led , HIGH );
}
// && is used to give and condition in the if statement
else if(v1>2. && v1<=3.){
Serial.println(" the voltage is medium");
}// || is used to give a or condition in the if statement
else{
Serial.println("sahi hai voltage");
digitalWrite(led , LOW);
}
}