int readPin=A3;
int time=400;
float volt;
int readVal;
int lPin=9;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(lPin,OUTPUT);
pinMode(readPin,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
readVal=analogRead(readPin);
volt=(5./1023.)*readVal;
Serial.print("Potentiometer Voltage =");
Serial.println(volt);
if (volt>2.0 && volt<3.0){
digitalWrite(lPin,HIGH);
}
if (volt<2.0 || volt>3.0){
digitalWrite(lPin,LOW);
}
delay(time);
}