#define LED_PIN 15
#define BUTTON_PIN 12
void LED_On()
{
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
}
void LED_Off()
{
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
}
bool button_up = true;
bool led_stat = false;
void setup() {
Serial.begin(115200);
LED_Off();
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW)
{
if (button_up)
{
button_up = false;
led_stat = !led_stat;
}
}
else
{
button_up = true;
}
if (led_stat)
LED_On();
else
LED_Off();
delay(10); // this speeds up the simulation
}