#include <ezButton.h>

#define DEBOUNCE_TIME 20 // the debounce time in millisecond, increase this time if it still chatters

int LightSwitch = 0;

// Buttons
ezButton button1(2); // create ezButton object that attach to pin GIOP22

// LED 1
#define LED1_RED 12
#define LED1_GREEN 13
#define LED1_BLUE 14
// LED 2
#define LED2_RED 21
#define LED2_GREEN 22
#define LED2_BLUE 23

void setup() {
  button1.setDebounceTime(DEBOUNCE_TIME); // set debounce time to 50 milliseconds
  // LED 1
  pinMode(LED1_RED, OUTPUT);
  pinMode(LED1_GREEN, OUTPUT);
  pinMode(LED1_BLUE, OUTPUT);
  // LED 2
  pinMode(LED2_RED, OUTPUT);
  pinMode(LED2_GREEN, OUTPUT);
  pinMode(LED2_BLUE, OUTPUT);
}

void loop() {

  button1.loop(); // MUST call the loop() function first

  if (button1.isReleased()) {
    if (LightSwitch == 0) {
      LightSwitch = 1;
    } else {
      LightSwitch = 0;
    }
  }
    
  if (LightSwitch == 0) {
    // LED1 on
    analogWrite(LED1_RED,   0);
    analogWrite(LED1_GREEN, 255);
    analogWrite(LED1_BLUE,  0);
    // LED2 off
    analogWrite(LED2_RED,   0);
    analogWrite(LED2_GREEN, 0);
    analogWrite(LED2_BLUE,  0);
  } else {
    // LED1 off
    analogWrite(LED1_RED,   0);
    analogWrite(LED1_GREEN, 0);
    analogWrite(LED1_BLUE,  0);
    // LED2 on
    analogWrite(LED2_RED,   0);
    analogWrite(LED2_GREEN, 255);
    analogWrite(LED2_BLUE,  0);
  }
  
  
    

}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
rgb1:R
rgb1:COM
rgb1:G
rgb1:B
rgb2:R
rgb2:COM
rgb2:G
rgb2:B