Advertisement
pleasedontcode

"Button Detection" rev_02

Jan 10th, 2025
47
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: 2025-01-10 14:43:08
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* تنفيذ نظام اكتشاف ضغط الزر باستخدام مكتبة */
  21.     /* EasyButton، مما يضمن إدخالاً موثوقًا به من زر */
  22.     /* الضغط المتصل بالدبوس الرقمي D2 مع تكوين السحب */
  23.     /* لأعلى. */
  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 w_PushButton_PIN_D2       = 2;
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. EasyButton button(w_PushButton_PIN_D2); // Instance of the button
  40.  
  41. // Callback function to be called when the button is pressed.
  42. void onPressed()
  43. {
  44.   Serial.println("Button pressed");
  45. }
  46.  
  47. void setup(void)
  48. {
  49.     // put your setup code here, to run once:
  50.     pinMode(w_PushButton_PIN_D2, INPUT_PULLUP); // Configure pin as input with pull-up
  51.  
  52.     // Initialize Serial for debugging purposes.
  53.     Serial.begin(115200);
  54.     Serial.println();
  55.     Serial.println(">>> EasyButton pressed example <<<");
  56.  
  57.     // Initialize the button.
  58.     button.begin();
  59.     // Add the callback function to be called when the button is pressed.
  60.     button.onPressed(onPressed);
  61. }
  62.  
  63. void loop(void)
  64. {
  65.     // Continuously read the status of the button.
  66.     button.read();
  67. }
  68.  
  69. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement