pleasedontcode

Button Logger rev_15

Oct 5th, 2025
31
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 Logger
  13.     - Source Code NOT compiled for: XIAO ESP32S3
  14.     - Source Code created on: 2025-10-05 21:10:18
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* read button */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <EasyButton.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void buttonPressed();
  33.  
  34. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  35. const uint8_t button_PushButton_PIN_D0        = 0;
  36.  
  37. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/// Button instance attached to D0
  38. EasyButton button(button_PushButton_PIN_D0);
  39.  
  40. void buttonPressed()
  41. {
  42.   Serial.println("Button pressed");
  43. }
  44.  
  45. void setup(void)
  46. {
  47.   // put your setup code here, to run once:
  48.  
  49.   Serial.begin(115200);
  50.   Serial.println();
  51.   Serial.println(">>> POTATest.ino - Button read example <<<");
  52.  
  53.   // Configure the input pin with internal pull-up
  54.   pinMode(button_PushButton_PIN_D0, INPUT_PULLUP);
  55.  
  56.   // Initialize the EasyButton instance
  57.   button.begin();
  58.  
  59.   // Register the pressed callback
  60.   button.onPressed(buttonPressed);
  61. }
  62.  
  63. void loop(void)
  64. {
  65.   // Read the status of the button
  66.   button.read();
  67. }
  68.  
  69. /* END CODE */
  70.  
Advertisement
Add Comment
Please, Sign In to add comment