Created
June 27, 2020 18:43
-
-
Save apotox/be6a8fda2618f59c4dc35101fd056bb6 to your computer and use it in GitHub Desktop.
attachInterrupt example for the atmega328
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
const byte ledPin = 13; | |
const byte interruptPin = 2; | |
volatile byte state = LOW; | |
void setup() { | |
pinMode(ledPin, OUTPUT); | |
pinMode(interruptPin, INPUT_PULLUP); | |
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE); | |
} | |
void loop() { | |
digitalWrite(ledPin, state); | |
} | |
void blink() { | |
state = !state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description here