Advertisement
pleasedontcode

Button Detection rev_02

May 16th, 2024
659
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 compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-05-17 04:06:31
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Improve the user description requirement by */
  21.     /* specifying the need for debouncing for the push */
  22.     /* button connected to pin D4 using the EasyButton */
  23.     /* library. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  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 = 4;
  36.  
  37. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  38. EasyButton button(BUTTON_PIN);
  39.  
  40. void onPressed()
  41. {
  42.   Serial.println("Button pressed");
  43. }
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.   Serial.begin(115200);
  49.   Serial.println();
  50.   Serial.println(">>> EasyButton pressed example <<<");
  51.  
  52.   // Initialize the EasyButton object with debouncing for the push button connected to pin D4 using the EasyButton library
  53.   button.begin();
  54.   button.onPressed(onPressed);
  55. }
  56.  
  57. void loop(void)
  58. {
  59.   // put your main code here, to run repeatedly:
  60.   button.read();
  61. }
  62.  
  63. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement