//2025.07.04
//#define button 46 문제있어서 gpio 13으로 바꿈
#define LED 13
#define button 8

int key_ok = 0;  //Define the data variables needed for the project
int LED_en = 0;

void setup() {
  pinMode(button, INPUT);  //Define the operation mode of the pin
  pinMode(LED, OUTPUT);
}

void loop() {
  // Determine if a button has been pressed and read the button level
  if (digitalRead(button)) {
    if (key_ok)  // Determine if the button is pressed
    {
      key_ok = 0;
      if (LED_en) LED_en = 0;  // Determines whether the last flag bit is established
      else LED_en = 1;
    }
  } else {
    delay(20);
    if (!digitalRead(button)) key_ok = 1;
  }

  // When the key is pressed, the level of the LED light output pin is reversed
  if (LED_en) digitalWrite(LED, HIGH);
  else digitalWrite(LED, LOW);
}
