Last active
August 29, 2015 14:20
-
-
Save jscrane/28db46e7842d374c3150 to your computer and use it in GitHub Desktop.
Interrupted example for ATtiny85
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
#include <Interrupted.h> | |
#define LED 0 | |
#define TIMER 1 | |
#define BUTTON 2 | |
Watchdog timer(TIMER, 1); | |
External button(BUTTON, LOW); | |
PinChangeGroup portb; | |
PinChange led(LED, portb); | |
Devices devices; | |
void setup(void) | |
{ | |
devices.add(timer); | |
devices.add(led); | |
devices.add(button); | |
devices.begin(); | |
pinMode(LED, OUTPUT); | |
digitalWrite(LED, HIGH); | |
} | |
void loop(void) | |
{ | |
switch (devices.select()) { | |
case BUTTON: | |
digitalWrite(LED, HIGH); | |
break; | |
case TIMER: | |
digitalWrite(LED, LOW); | |
break; | |
case LED: | |
timer.enable(led.is_on()); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment