Advertisement
pleasedontcode

"Button Debouncing" rev_01

Feb 25th, 2025
346
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 Debouncing"
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-02-26 02:51:48
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The project shall implement a setup routine to */
  21.     /* configure hardware components and a loop to manage */
  22.     /* real-time operations, ensuring responsive behavior */
  23.     /* to user commands and sensor inputs. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t myPushButton_PushButton_PIN_D2        = 2;
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. EasyButton myButton(myPushButton_PushButton_PIN_D2); // Create an instance of EasyButton
  40.  
  41. void setup(void)
  42. {
  43.     // put your setup code here, to run once:
  44.     pinMode(myPushButton_PushButton_PIN_D2, INPUT_PULLUP);
  45.     myButton.begin(); // Initialize the button
  46. }
  47.  
  48. void loop(void)
  49. {
  50.     // put your main code here, to run repeatedly:
  51.     myButton.update(); // Update the button state
  52.  
  53.     if (myButton.isPressed()) {
  54.         // Code to execute when the button is pressed
  55.     }
  56. }
  57.  
  58. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement