-
-
Save JeffersGlass/4570f0a24cfaa5683aec3a3bb9d1b916 to your computer and use it in GitHub Desktop.
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 int button = PORTD5; | |
const int led = PORTD2; | |
void setup() { | |
// put your setup code here, to run once: | |
DDRD = _BV(led); //Configure LED for output, button is input | |
PORTD = _BV(button); //Enable button on button pin | |
PCICR = _BV(PCIE0); //Enable Pin Change Interrupt 0 | |
PCMSK0 = _BV(PCINT5); //Mask out all other bits besides pin 5 (button) | |
} | |
void loop() { | |
} | |
ISR(PCINT0_vect){ //When button changes state, | |
PORTD ^= _BV(led); //Toggle LED | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment