/********* 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: Button Detection
- Source Code NOT compiled for: ESP8266 NodeMCU V1.0
- Source Code created on: 2024-10-29 23:20:58
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* print on serial push button. */
/****** END SYSTEM REQUIREMENTS *****/
/* START CODE */
/****** 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 but_PushButton_PIN_D1 = 1;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
EasyButton button(but_PushButton_PIN_D1); // Instance of the button
// Callback function to be called when the button is pressed.
void onPressed() {
Serial.println("Button pressed"); // Print message on serial
}
void setup(void) {
// put your setup code here, to run once:
Serial.begin(115200); // Initialize Serial for debugging purposes
Serial.println(); // Print a new line
Serial.println(">>> EasyButton pressed example <<<"); // Print example header
pinMode(but_PushButton_PIN_D1, INPUT_PULLUP); // Set the button pin as input with pull-up resistor
button.begin(); // Initialize the button
button.onPressed(onPressed); // Add the callback function for button press
}
void loop(void) {
// Continuously read the status of the button.
button.read(); // Read the button state
}
/* END CODE */