#include <stdbool.h>
#include <stdio.h>
//Button Press Lights Up LED
const int buttonPin = D0;
const int ledPin = D4;
int pressCount = 1;
int buttonState = 0;
bool running = false;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
//printing console initialize
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
while (digitalRead(buttonPin) == HIGH) {
digitalWrite(ledPin, HIGH);
if (!running) {
running = true;
Serial.print("BUTTON PRESSED ! -->");
Serial.println(pressCount);
pressCount++;
}
}
running = false;
digitalWrite(ledPin, LOW);
}