Advertisement
pleasedontcode

EasyButton Events rev_01

May 16th, 2024
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: EasyButton Events
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-05-17 04:05:15
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Improve the user description requirement by */
  21.     /* specifying the need for debouncing for the push */
  22.     /* button connected to pin D4 using the EasyButton */
  23.     /* library. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <EasyButton.h> // https://github.com/evert-arias/EasyButton
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  34. const uint8_t BUTTON_PIN = 4;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  37. EasyButton button(BUTTON_PIN);
  38.  
  39. void onPressed()
  40. {
  41.   Serial.println("Button pressed");
  42. }
  43.  
  44. void setup(void)
  45. {
  46.   // put your setup code here, to run once:
  47.   Serial.begin(115200);
  48.   Serial.println();
  49.   Serial.println(">>> EasyButton pressed example <<<");
  50.  
  51.   // Initialize the EasyButton object with debouncing for the push button connected to pin D4 using the EasyButton library
  52.   button.begin();
  53.   button.onPressed(onPressed);
  54. }
  55.  
  56. void loop(void)
  57. {
  58.   // put your main code here, to run repeatedly:
  59.   button.read();
  60. }
  61.  
  62. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement