int myVoltPin = A5;
int readVol ;
int LedPinR = 9;
int LedPinY = 8;
int LedPinG = 11;
float V2;
int delayT = 500;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LedPinR, OUTPUT);
pinMode(LedPinG, OUTPUT);
pinMode(LedPinY, OUTPUT);
pinMode(myVoltPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
readVol = analogRead(myVoltPin);
V2 = (5./1023.)*readVol;
Serial.print("Potentiometer Voltage is ");
Serial.println(V2);
delay(delayT);
if (V2>3.0 && V2<4.0){
digitalWrite(LedPinY, HIGH);
}else{
digitalWrite(LedPinY, LOW);
}
if (V2<=3.0 ){
digitalWrite(LedPinR, HIGH);
}else{
digitalWrite(LedPinR, LOW);
}
if (V2>=4.0){
digitalWrite(LedPinG, HIGH);
}else{
digitalWrite(LedPinG, LOW);
}
}