Skip to content

Instantly share code, notes, and snippets.

@stiplady
Last active January 25, 2022 19:10
Show Gist options
  • Select an option

  • Save stiplady/e1d5e98067b324fad15c8298bf983856 to your computer and use it in GitHub Desktop.

Select an option

Save stiplady/e1d5e98067b324fad15c8298bf983856 to your computer and use it in GitHub Desktop.
int ledPin = 13; // Output connected to digital pin 13
int inPin = 7; // input connected to digital pin 7
int pinState = LOW;
void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
digitalWrite(ledPin, LOW);
}
void loop() {
if ( HIGH == digitalRead(inPin) ) {
digitalWrite(ledPin, HIGH); // sets the output high (on)
delay(5000); // 5 seconds
digitalWrite(ledPin, LOW); // sets output low (off)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment