Advertisement
pleasedontcode

Button Detection rev_01

Oct 13th, 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-10-13 16:20:12
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Implementar una interfaz de usuario para el */
  21.     /* proyecto "wampankith" que aproveche la biblioteca */
  22.     /* EasyButton para un manejo perfecto de los botones, */
  23.     /* garantizando una entrada confiable desde el botón */
  24.     /* pulsador en el pin D2. */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <EasyButton.h> // https://github.com/evert-arias/EasyButton
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  35. const uint8_t BUTTON_PIN_D2 = 2; // Define the pin for the push button
  36.  
  37. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  38. // Initialize the EasyButton object for the push button
  39. EasyButton button(BUTTON_PIN_D2);
  40.  
  41. /****** FUNCTION DEFINITIONS *****/
  42. void setup(void)
  43. {
  44.     // Start serial communication for debugging
  45.     Serial.begin(115200);
  46.    
  47.     // Print a message to the Serial Monitor
  48.     Serial.println();
  49.     Serial.println(">>> EasyButton example <<<");
  50.  
  51.     // Initialize the button
  52.     button.begin();
  53.    
  54.     // Set the button press event
  55.     button.onPressed([]() {
  56.         Serial.println("Button pressed"); // Action to perform when button is pressed
  57.     });
  58. }
  59.  
  60. void loop(void)
  61. {
  62.     // Continuously read the button state
  63.     button.read();
  64. }
  65.  
  66. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement