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: Example
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-29 19:06:39
- - Source Code generated by: Francesco
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <EasyButton.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Give me an example of usage of the button */
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t BUTTON_PIN = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button(BUTTON_PIN);
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(115200);
- Serial.println();
- Serial.println(">>> EasyButton pressed example <<<");
- // Set the button pin as input with internal pull-up resistor enabled
- pinMode(BUTTON_PIN, INPUT_PULLUP);
- // Initialize the button object
- button.begin();
- button.onPressed([]() {
- // Button is pressed, perform the desired action
- Serial.println("Button pressed");
- });
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Update the button state
- button.update();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement