Feed ID 1987822557
API jUcsazOPTxgI3eenF8a9vpqlJFwFi5AlbRf4xzsvGSmXXOnZ
// These constants won’t change:
const int analogPin = A1; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to
const int threshold = 1023; // an arbitrary threshold level that’s in the range of the analog input
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
// if the analog value is high enough, turn on the LED:
if (analogValue < threshold) {
digitalWrite(ledPin, HIGH);
delay(30000);
}
else {
digitalWrite(ledPin,LOW);
delay(5000);
}
// print the analog value:
Serial.println(analogValue);
delay(1); // delay in between reads for stability
}