//variable
int sensorPin = A0;
int sensorValue = 0;
void setup (){
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(9, OUTPUT); // initialize pin 9 as an output
}
void loop(){
sensorValue = analogRead(sensorPin); //read analog value from pin A0
Serial.println (sensorValue); //Show the read result on log
float voltage = sensorValue * (5.0/1023.0); //formula to calculate the voltage
Serial.println(voltage); //show the voltage result on log
if(voltage>=1){
digitalWrite (9, HIGH);}
else{
digitalWrite(9, LOW);
}
delay(1000);
}