Advertisement
pleasedontcode

Button Monitor rev_01

Feb 13th, 2024
67
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 Monitor
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-02-13 10:07:47
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Bluetoot connection */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <EasyButton.h> // Library for button handling
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup();
  28. void loop();
  29.  
  30. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  31. const uint8_t buttonPin = 4; // Pin connected to the push button
  32.  
  33. /****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
  34. EasyButton myButton(buttonPin); // Button object instance
  35.  
  36. void setup()
  37. {
  38.   // put your setup code here, to run once:
  39.  
  40.   pinMode(buttonPin, INPUT_PULLUP); // Set the push button pin as input with internal pull-up resistor
  41.  
  42.   // Initialize the EasyButton object
  43.   myButton.begin();
  44. }
  45.  
  46. void loop()
  47. {
  48.   // put your main code here, to run repeatedly:
  49.  
  50.   // Read the button state
  51.   myButton.read();
  52.  
  53.   // check if the button has been pressed
  54.   if (myButton.wasPressed())
  55.   {
  56.     // Action to be performed when the button is pressed
  57.     Serial.println("Button has been pressed");
  58.   }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement