Advertisement
pleasedontcode

Button Detection rev_01

Sep 25th, 2024
59
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-09-25 13:10:00
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Kullanıcı etkileşimleri için dijital pin D2'de */
  21.     /* INPUT_PULLUP yapılandırmasıyla güvenilir giriş */
  22.     /* işleme sağlayarak EasyButton kitaplığını */
  23.     /* kullanarak bir düğme arabirimi uygulayın. */
  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 v_PushButton_PIN_D2 = 2;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  37. // Initialize the EasyButton object for the push button on pin D2
  38. EasyButton button1(v_PushButton_PIN_D2, 35, true, true); // Debounce time 35ms, pullup enabled, active low
  39.  
  40. /****** FUNCTION DEFINITIONS *****/
  41. void setup(void)
  42. {
  43.     // Start the serial communication for debugging
  44.     Serial.begin(115200);
  45.    
  46.     // Print a welcome message to the serial monitor
  47.     Serial.println();
  48.     Serial.println(">>> EasyButton example <<<");
  49.  
  50.     // Initialize the button
  51.     button1.begin();
  52.    
  53.     // Set the button press event handler
  54.     button1.onPressed([]() {
  55.         Serial.println("Button pressed");
  56.     });
  57. }
  58.  
  59. void loop(void)
  60. {
  61.     // Continuously read the button state
  62.     button1.read();
  63. }
  64.  
  65. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement