Skip to content

Instantly share code, notes, and snippets.

@neoneo40
Created December 9, 2014 06:41
Show Gist options
  • Save neoneo40/b88f60df91a17438b0f0 to your computer and use it in GitHub Desktop.
Save neoneo40/b88f60df91a17438b0f0 to your computer and use it in GitHub Desktop.
int before_sw = HIGH;
void setup() {
Serial.begin(9600);
pinMode(9, INPUT_PULLUP);
pinMode(13, OUTPUT);
}
void loop() {
if(digitalRead(9) == LOW && before_sw == HIGH)
{
before_sw = LOW;
if(digitalRead(13) == HIGH) digitalWrite(13, LOW);
else digitalWrite(13, HIGH);
}
else if(digitalRead(9) == HIGH)
{
before_sw = HIGH;
}
// delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment