#include <mechButton.h> // We want the mechButton from the LC_baseTools library.
mechButton modeSwitch(2); // OUr mode button is connected to pin 2.
// Your standard Arduino setup function.
void setup() {
pinMode(3,OUTPUT); // First LED setup.
pinMode(4,OUTPUT); // Second LED setup.
modeSwitch.setCallback(switchChange); // When the stwich changes state, this function will be called.
setMode(modeSwitch.trueFalse()); // Set the mode to whatever the state of the switch is in now.
}
// This function does whatever needed to switch modes. In this case it swaps LEDs
void setMode(bool newMode) {
if (newMode) {
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
} else {
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
}
}
// This gets called whenever the switch changes. Used to change the mode.
void switchChange(void) { setMode(modeSwitch.trueFalse()); }
// Only thing in loop now is the idle call for background code. IE the mechButton runs in the background.
void loop() { idle(); }