/********* 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 Callbacks - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-10-03 10:57:01 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* liga envia uma mensagem para o serial, desliga faz */ /* o mesmo */ /****** 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 button_PushButton_PIN_D4 = 4; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Create an instance of the EasyButton class, passing the button pin as an argument EasyButton button(button_PushButton_PIN_D4); // Correctly instantiate the EasyButton object void setup(void) { // Initialize Serial communication for debugging Serial.begin(115200); Serial.println(">>> EasyButton setup <<<"); // Initialize the button button.begin(); // Call the begin method to set up the button // Add a callback function to be called when the button is pressed button.onPressed([]() { Serial.println("Button pressed"); // Send message when button is pressed }); // Add a callback function to be called when the button is released button.onReleased([]() { Serial.println("Button released"); // Send message when button is released }); } void loop(void) { // Continuously read the status of the button button.read(); // This checks the button state and triggers the callback if pressed } /* END CODE */