Advertisement
pleasedontcode

Button Detection rev_01

Aug 28th, 2024
148
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 Detection
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-08-28 18:15:49
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* تنفيذ نظام اكتشاف ضغط الزر باستخدام مكتبة */
  21.     /* EasyButton، مما يضمن إدخالاً موثوقًا به من زر */
  22.     /* الضغط المتصل بالدبوس الرقمي D2 مع تكوين السحب */
  23.     /* لأعلى. */
  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 w_PushButton_PIN_D2 = 2;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  37. // Instantiate the EasyButton object for the push button with pull-up enabled
  38. EasyButton button(w_PushButton_PIN_D2, 35, true, true); // debounce_time = 35ms, pullup_enable = true, active_low = true
  39.  
  40. /****** FUNCTION DEFINITIONS *****/
  41. // Function to be called when the button is pressed
  42. void onButtonPressed() {
  43.     Serial.println("Button pressed"); // Print message when button is pressed
  44. }
  45.  
  46. void setup(void) {
  47.     // Initialize serial communication
  48.     Serial.begin(115200);
  49.  
  50.     // Print a message to indicate the setup has started
  51.     Serial.println();
  52.     Serial.println(">>> EasyButton example <<<");
  53.  
  54.     // Initialize the button
  55.     button.begin();
  56.     // Attach the onButtonPressed function to the button press event
  57.     button.onPressed(onButtonPressed);
  58. }
  59.  
  60. void loop(void) {
  61.     // Continuously read the button state
  62.     button.read();
  63. }
  64.  
  65. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement