Skip to content

Instantly share code, notes, and snippets.

@Thiemann96
Created August 8, 2019 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thiemann96/a820e452f21159842b1673280ad3d9ed to your computer and use it in GitHub Desktop.
Save Thiemann96/a820e452f21159842b1673280ad3d9ed to your computer and use it in GitHub Desktop.
Simple Arduino Sketch that Interrupts blinking on a button click
/*
digitalRead(0)
1 - Nix
0 - Button ist gedrückt
*/
bool interrupted = false;
void setup(){
Serial.begin(9600);
pinMode(0,INPUT);
pinMode(7,OUTPUT);
attachInterrupt(digitalPinToInterrupt(0), interrupt, CHANGE);
}
void loop(){
if(!interrupted){
digitalWrite(8,HIGH);
delay(250);
digitalWrite(8,LOW);
delay(250);
}
}
void interrupt(){
Serial.print("Interrupting here");
interrupted = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment