pleasedontcode

EasyButton Events rev_01

Aug 25th, 2025
372
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: Arduino Mega
  14.     - Source Code created on: 2025-08-25 09:48:42
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* simplify the given code */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  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. void powerOnPressed();
  34. void analysePressed();
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t powerOn_PushButton_PIN_D2 = 2;
  38. const uint8_t analyse_PushButton_PIN_D3 = 3;
  39.  
  40. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  41. EasyButton powerOnBtn(powerOn_PushButton_PIN_D2);
  42. EasyButton analyseBtn(analyse_PushButton_PIN_D3);
  43.  
  44. void setup(void)
  45. {
  46.     // put your setup code here, to run once:
  47.  
  48.     Serial.begin(9600);
  49.  
  50.     // Initialize pins with internal pull-ups
  51.     pinMode(powerOn_PushButton_PIN_D2, INPUT_PULLUP);
  52.     pinMode(analyse_PushButton_PIN_D3, INPUT_PULLUP);
  53.  
  54.     // Initialize EasyButton instances
  55.     powerOnBtn.begin();
  56.     analyseBtn.begin();
  57.  
  58.     // Attach callbacks
  59.     powerOnBtn.onPressed(powerOnPressed);
  60.     analyseBtn.onPressed(analysePressed);
  61. }
  62.  
  63. void loop(void)
  64. {
  65.     // put your main code here, to run repeatedly:
  66.  
  67.     powerOnBtn.read();
  68.     analyseBtn.read();
  69. }
  70.  
  71. void powerOnPressed()
  72. {
  73.     Serial.println("Power On Button pressed");
  74. }
  75.  
  76. void analysePressed()
  77. {
  78.     Serial.println("Analyse Button pressed");
  79. }
  80.  
  81. /* END CODE */
  82.  
Advertisement
Add Comment
Please, Sign In to add comment