/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: LED Blink
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-10-22 19:14:18
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* po naciśnieciu mrugaj */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include // https://github.com/evert-arias/EasyButton
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t switch_PushButton_PIN_D4 = 4; // Button pin
const uint8_t led_PIN = 13; // LED pin (usually built-in on many boards)
/****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
// Instance of the button, initialized with the pin number and default parameters
EasyButton button(switch_PushButton_PIN_D4); // Using the constructor of EasyButton
void setup(void)
{
// put your setup code here, to run once:
Serial.begin(115200); // Initialize Serial communication for debugging
Serial.println(">>> EasyButton example <<<");
// Initialize the button
button.begin(); // Set up the button
button.onPressed([]() { // Lambda function to handle button press
Serial.println("Button pressed");
// Blink the LED when the button is pressed
for (int i = 0; i < 5; i++) { // Blink 5 times
digitalWrite(led_PIN, HIGH); // Turn on LED
delay(100); // Keep LED on for 100 milliseconds
digitalWrite(led_PIN, LOW); // Turn off LED
delay(100); // Keep LED off for 100 milliseconds
}
});
pinMode(switch_PushButton_PIN_D4, INPUT_PULLUP); // Set the button pin as input with pull-up resistor
pinMode(led_PIN, OUTPUT); // Set the LED pin as output
}
void loop(void)
{
// put your main code here, to run repeatedly:
button.read(); // Continuously read the button state
}
/* END CODE */