#include int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 5; // select the pin for the LED float value = 0; // variable to store the value coming from the sensor void setup() { // declare the ledPin as an OUTPUT: Serial.begin(115200); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); } void loop() { // read the value from the sensor: //value = analogRead(sensorPin); for(int i=0;i<40;i++) { value += analogRead(sensorPin); } value = value/1024.00; Serial.println(value); if(value > 0.05) { delay(2000); float value2 = 0; for(int i=0;i<40;i++) { value2 += analogRead(sensorPin); } value2 = value2/1024.00; if(value2 > 0.05) { digitalWrite(ledPin, HIGH); delay(2000);} else { digitalWrite(ledPin, LOW); delay(2000);} } }