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 Handling**
- - Source Code compiled for: ESP8266 NodeMCU V1.0
- - Source Code created on: 2024-10-30 00:02:47
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* print on serial push button. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> // https://github.com/evert-arias/EasyButton
- /****** FUNCTION PROTOTYPES *****/
- void setup(void); // Added missing semicolon
- void loop(void); // Added missing semicolon
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t but_PushButton_PIN_D1 PROGMEM = 1; // Store in flash memory to save RAM
- /****** 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(F("Button pressed")); // Use F() macro to store string in flash memory
- }
- 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(F(">>> EasyButton pressed example <<<")); // Use F() macro for flash memory
- 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 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement