Advertisement
pleasedontcode

Button Manager rev_01

Oct 15th, 2024
80
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: Button Manager
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-10-15 10:12:10
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Hfyunyhsywbwybdhd */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <EasyButton.h>  // https://github.com/evert-arias/EasyButton
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  31. const uint8_t Mydot_PushButton_PIN_D4 = 4;
  32. const uint8_t Mydot_PushButton_PIN_D13 = 13;
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  35. // Create instances of EasyButton for each button
  36. EasyButton button1(Mydot_PushButton_PIN_D4);  // Button connected to pin D4
  37. EasyButton button2(Mydot_PushButton_PIN_D13); // Button connected to pin D13
  38.  
  39. void setup(void)
  40. {
  41.     // Initialize Serial for debugging purposes
  42.     Serial.begin(115200);
  43.     Serial.println();
  44.     Serial.println(">>> EasyButton example with multiple buttons <<<");
  45.  
  46.     // Initialize the buttons
  47.     button1.begin();
  48.     button2.begin();
  49.  
  50.     // Set up callbacks for button presses
  51.     button1.onPressed([]() {
  52.         Serial.println("Button on D4 pressed");
  53.     });
  54.     button2.onPressed([]() {
  55.         Serial.println("Button on D13 pressed");
  56.     });
  57. }
  58.  
  59. void loop(void)
  60. {
  61.     // Continuously read the status of the buttons
  62.     button1.read();
  63.     button2.read();
  64. }
  65.  
  66. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement