Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: ESP32 DevKit V1
- - Source Code created on: 2024-08-09 17:03:54
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* The project requires integration of the EasyButton */
- /* library to handle button interactions on digital */
- /* pin D4, ensuring it operates with INPUT_PULLUP for */
- /* enhanced input stability. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t boton_PushButton_PIN_D4 = 4;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Initialize the EasyButton object for the defined pin
- EasyButton button(boton_PushButton_PIN_D4);
- /****** FUNCTION DEFINITIONS *****/
- // Function to be called when the button is pressed
- void onButtonPressed() {
- Serial.println("Button pressed");
- }
- void setup(void)
- {
- // Start serial communication for debugging
- Serial.begin(115200);
- // Set the button pin mode to INPUT_PULLUP for enhanced input stability
- pinMode(boton_PushButton_PIN_D4, INPUT_PULLUP);
- // Initialize the button with the defined pin
- button.begin();
- // Attach the onPressed function to the button
- button.onPressed(onButtonPressed);
- }
- void loop(void)
- {
- // Call the read function to check the button state
- button.read();
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement