Created
August 8, 2019 13:59
-
-
Save Thiemann96/a820e452f21159842b1673280ad3d9ed to your computer and use it in GitHub Desktop.
Simple Arduino Sketch that Interrupts blinking on a button click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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