Skip to content

Instantly share code, notes, and snippets.

@jscrane
Last active August 29, 2015 14:20
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 jscrane/28db46e7842d374c3150 to your computer and use it in GitHub Desktop.
Save jscrane/28db46e7842d374c3150 to your computer and use it in GitHub Desktop.
Interrupted example for ATtiny85
#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