Class BlinkPlug
The Blink Plug class has 4 methods for controlling the LEDs and reading the switches.
void BlinkPlug::ledOn (byte mask)
turns on an LED
void BlinkPlug::ledOff (byte mask)
turns off an LED
reads the state of the LEDs
byte BlinkPlug::buttonCheck ()
reads the states of the two buttons, includes 100 mS of switch debouncing resolves buttonDown and buttonUp events of both buttons
returns the state of the buttons deprecated - use buttonCheck() instead
Example
// Demo of the BlinkPlug class
// 2009-12-09 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
// Demonstrates blinking buttons and checking button transitions
#include <JeeLib.h>
BlinkPlug myBP (1+2); // initialize both buttons
void setup () {
Serial.begin(57600);
Serial.println("\n[blink_demo]");
for (byte i = 0; i < 3; ++i) { // cycle LEDs 3 times
myBP.ledOn(1);
delay(500);
myBP.ledOn(2);
delay(500);
myBP.ledOff(1+2);
delay(500);
}
}
int rate = 750;
MilliTimer blink;
byte on;
void loop () {
byte pushedEvent = myBP.pushed();
Serial.print("pushed = ");
Serial.print(pushedEvent);
byte buttonEvents = myBP.buttonCheck();
Serial.print(" buttons = ");
Serial.print(buttonEvents);
}