Skip to content

Instantly share code, notes, and snippets.

@mattbowen
Created March 8, 2010 03:45
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 mattbowen/324832 to your computer and use it in GitHub Desktop.
Save mattbowen/324832 to your computer and use it in GitHub Desktop.
#include <LED.h>
#include <Button.h>
const int AVAILABLE_LED = 2;
const int BUSY_LED = 3;
const int INTERRUPTED_LED = 4;
Button btn_interrupted = Button(12,PULLUP);
Button btn_available = Button(8,PULLUP);
Button btn_busy = Button(9, PULLUP);
LED led_available = LED(AVAILABLE_LED);
LED led_busy = LED(BUSY_LED);
LED led_interrupted = LED(INTERRUPTED_LED);
boolean is_busy = false;
void setup() {
}
void loop() {
if (btn_available.isPressed()) {
set_available();
}
if(btn_busy.isPressed()) {
set_busy();
}
if(is_busy && btn_interrupted.isPressed()) {
note_interruption();
}
}
void set_available() {
is_busy = false;
led_available.on();
led_busy.off();
}
void set_busy() {
is_busy = true;
led_busy.on();
led_available.off();
}
void note_interruption() {
for(int i = 0; i < 6; i++) {
led_interrupted.toggle();
delay(200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment