#include <mechButton.h> // Add a button manager library..

// DEFINE ALL PINS
const int BUTTON_GREEN_PIN = 5;
const int BUTTON_RED_PIN = 6;
const int LED_GREEN_PIN = 7;
const int LED_RED_PIN = 8;

// DEFINE HIGH/LOW STATE VARIABLES
bool LED_GREEN_STATE = false;
bool LED_RED_STATE = false;

mechButton  greenBtn(BUTTON_GREEN_PIN);
mechButton  redBtn(BUTTON_RED_PIN);

void setup() {
  
  pinMode(LED_GREEN_PIN, OUTPUT);
  pinMode(LED_RED_PIN, OUTPUT);
  greenBtn.setCallback(greenClk);
  redBtn.setCallback(redClk);
}


// When green changes state, this is called.
void greenClk(void) {

  if (!greenBtn.getState()) {                     // Check if the green button was pressed.
    LED_GREEN_STATE = !LED_GREEN_STATE;           // Flip the green state.
    digitalWrite(LED_GREEN_PIN,LED_GREEN_STATE);  // Set the green LED.
  }                                               // And we are done.
}


void redClk(void) {

  if (!redBtn.getState()) {                       // Check if the red button was pressed.
    LED_RED_STATE = !LED_RED_STATE;               // Flip the red state.
    digitalWrite(LED_RED_PIN,LED_RED_STATE);      // Set the red LED.
  }                                               // And we are done.
}


void loop() {
    idle();   // Runs the background tasks, like the buttons, for you.
    
    // Do whatever else you like here..

}