Skip to content

Instantly share code, notes, and snippets.

@glyons
Created February 1, 2019 18:21
Show Gist options
  • Select an option

  • Save glyons/37e41340645db518e618ffa7c86e9231 to your computer and use it in GitHub Desktop.

Select an option

Save glyons/37e41340645db518e618ffa7c86e9231 to your computer and use it in GitHub Desktop.
Digispark 1 second delay button with on board LED
int led =1 ; // Ues on board LED
int button=2; // Button to 5V Rail and 10k register on P2 to GND
int status = false;
void setup() {
digitalWrite(led, LOW);
pinMode(led, OUTPUT);
digitalWrite(button,LOW);
pinMode(button,INPUT);
}
void loop() {
if (digitalRead(button) == HIGH) {
status = !status;
delay(1000);
digitalWrite(led, status);
} while(digitalRead(button) == LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment