#include <Arduino.h>
#include <ezButton.h>

#define redLEDPin 13
#define greenLEDPin 12
#define blueLEDPin 14

ezButton buttonRed(2);
ezButton buttonGreen(4);
ezButton buttonBlue(5);

bool redLEDOn = false;
bool greenLEDOn = false;
bool blueLEDOn = false;

void displayRed();
void displayGreen();
void displayBlue();
void displayOff();

void setup() {
pinMode(redLEDPin, OUTPUT);
pinMode(greenLEDPin, OUTPUT);
pinMode(blueLEDPin, OUTPUT);
buttonRed.setDebounceTime(25);
buttonGreen.setDebounceTime(25);
buttonBlue.setDebounceTime(25);
}

void loop() {
  delay(10);
buttonRed.loop();
buttonGreen.loop();
buttonBlue.loop();

if (buttonRed.isPressed()) {
  if (redLEDOn == false) {
    redLEDOn = true;
    greenLEDOn = false;
    blueLEDOn = false;
    displayRed();
  } else {
    redLEDOn = false;
    displayOff();
    }
}
  if (buttonGreen.isPressed()) {
    if (greenLEDOn == false) {
      redLEDOn = false;
      greenLEDOn = true;
      blueLEDOn = false;
      displayGreen();
    } else {
      greenLEDOn = false;
      displayOff();
    }
}
  if (buttonBlue.isPressed()) {
    if (blueLEDOn == false) {
      redLEDOn = false;
      greenLEDOn = false;
      blueLEDOn = true;
      displayBlue();
    } else {
      blueLEDOn = false;
      displayOff();
    }
  }
}

void displayRed() {
    digitalWrite(redLEDPin, HIGH);
    digitalWrite(greenLEDPin, LOW);
    digitalWrite(blueLEDPin, LOW);
}

void displayGreen() {
    digitalWrite(redLEDPin, LOW);
    digitalWrite(greenLEDPin, HIGH);
    digitalWrite(blueLEDPin, LOW);
}

void displayBlue() {
    digitalWrite(redLEDPin, LOW);
    digitalWrite(greenLEDPin, LOW);
    digitalWrite(blueLEDPin, HIGH);
}

void displayOff () {
    digitalWrite(redLEDPin, LOW);
    digitalWrite(greenLEDPin, LOW);
    digitalWrite(blueLEDPin, LOW);
}