#include <mechButton.h>
#include <timeObj.h>
#define PULSE_PIN 2 // Pin we'll hook the button to. The other side hooks to ground.
#define THING_PIN 13 // Shows the thing activity.
mechButton aButton(PULSE_PIN); // Set button to pin PULSE_PIN.
timeObj timeOutTimer(1000); // Set to the milisecond to time out. Change to 20ms?
void setup() {
pinMode(THING_PIN,OUTPUT); // Set up the LED pin for output.
aButton.setCallback(myCallback); // Set up our callback. (Also calls hookup() for idling.)
}
// This is the guy that's called when the button changes state.
void myCallback(void) {
if (!aButton.getState()) { // We act if pin goes low. Change yours to High?
digitalWrite(THING_PIN,HIGH); // Turn thing on.
timeOutTimer.start(); // Start the timeout timer.
}
}
// Your standard sketch loop()
void loop() {
idle(); // Let all the idlers have time to do their thing.
if (timeOutTimer.ding()) { // If the timeout timer expires..
digitalWrite(THING_PIN,LOW); // Shut off the pump.
timeOutTimer.reset(); // Reset the timer.
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r