//#include <ESP8266WiFi.h>
//const int LED_PIN = 14; // The LED is connected to pin 4
//const int BUTTON_PIN = 13; // The push button is connected to pin 2
const int LED_PIN = 14; // comment if espp8266
const int BUTTON_PIN = 13; // comment if espp8266
const int BUTTON_D8_PIN = 18; // comment if espp8266
int buttonPressCount = 0; // Counter for the number of button presses
int button8PressCount = 0; // Counter for the number of button presses
void setup() {
pinMode(LED_PIN, OUTPUT); // Set the LED pin as an output
pinMode(BUTTON_PIN, INPUT); // Set the button pin as an input
pinMode(BUTTON_D8_PIN, INPUT); // Set the button pin as an input
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Check the state of the button
int button8State = digitalRead(BUTTON_D8_PIN);
if (button8State == LOW) {
// If the button is pressed, turn the LED on for 0.2 seconds
digitalWrite(LED_PIN, HIGH);
delay(200);
digitalWrite(LED_PIN, LOW);
// Increment the button press counter and print the value to the serial output
button8PressCount++;
Serial.println(button8PressCount);
}
else {
// If the button is not pressed, turn the LED off
digitalWrite(LED_PIN, LOW);
}
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) {
// If the button is pressed, turn the LED on for 0.2 seconds
digitalWrite(LED_PIN, HIGH);
delay(200);
digitalWrite(LED_PIN, LOW);
// Increment the button press counter and print the value to the serial output
buttonPressCount++;
Serial.println(buttonPressCount);
}
else {
// If the button is not pressed, turn the LED off
digitalWrite(LED_PIN, LOW);
}
}