#include <timeObj.h> // We want a timer..
#include <mechButton.h> // And a debounced button.
mechButton deadmanButton(2); // Our button hooked to pin 2.
timeObj deadmanTimer(2000); // Our deadman timer.
void setup() {
pinMode(3,OUTPUT); // Pin 3 output for LEDs
digitalWrite(3,LOW); // Make sure they are off.
Serial.begin(9600); // Start serial to amuse user.
Serial.println("Hit the button faster than once every two seconds."); // Print instructions.
Serial.println(" OR ELSE!"); //
deadmanButton.setCallback(clicked); // Call this function when clicked.
}
// This will be called when the button changes state.
void clicked(void) {
if (!deadmanButton.trueFalse()) { // If the click is false (Grounded down)
deadmanTimer.start(); // Restart the deadman timer.
}
}
void loop() {
idle(); // Idle runs stuff in bakcground. Example the button.
if (deadmanTimer.ding()) { // If the timers expires..
digitalWrite(3,HIGH); // Turn on the red LEDs.
Serial.println("**** BLAM! ****"); // BLAM!!
Serial.println(" Game over"); //
while(1); // Lock the process forever.
}
}