const int BUTTON_PIN = 7; // the number of the pushbutton pin
const int LED_PIN = 3; // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
// initialize the pushbutton pin as an pull-up input:
// the pull-up input pin will be HIGH when the switch is open and LOW when the switch is closed.
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
buttonState = digitalRead(BUTTON_PIN);
if(buttonState == LOW)
{
Serial.println("Light On");
digitalWrite(LED_PIN, HIGH);
delay(3000);
}
else
{
Serial.println("Light off");
digitalWrite(LED_PIN, LOW);
}
delay(100); //let everything settle
}