Advertisement
pleasedontcode

"Button Detection" rev_02

May 27th, 2024
580
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: ESP32 DevKit V1
  14.     - Source Code created on: 2024-05-27 13:32:22
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Develop a Ben10 Omnitrix project using an Arduino */
  21.     /* with a TFT round display and a push button */
  22.     /* connected to pin D4. Utilize the EasyButton */
  23.     /* library for button handling. Ensure the setup */
  24.     /* initializes the button with INPUT_PULLUP mode. */
  25. /****** SYSTEM REQUIREMENT 2 *****/
  26.     /* Develop a Ben10 Omnitrix project using an Arduino */
  27.     /* with a TFT round display and a push button */
  28.     /* connected to pin D4. Utilize the EasyButton */
  29.     /* library for button handling and ensure the setup */
  30.     /* initializes the button with INPUT_PULLUP mode.with */
  31.     /* images of ali */
  32. /****** END SYSTEM REQUIREMENTS *****/
  33.  
  34. /****** DEFINITION OF LIBRARIES *****/
  35. #include <EasyButton.h>  // https://github.com/evert-arias/EasyButton
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40. void onPressed(void);  // Prototype for the button press callback function
  41.  
  42. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  43. const uint8_t TFTrounddisplay_PushButton_PIN_D4 = 4;
  44.  
  45. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  46. EasyButton button(TFTrounddisplay_PushButton_PIN_D4);  // Initialize EasyButton with the pin
  47.  
  48. void onPressed()
  49. {
  50.   Serial.println("Button pressed");  // Callback function for button press
  51. }
  52.  
  53. void setup(void)
  54. {
  55.   // Initialize serial communication
  56.   Serial.begin(115200);  
  57.   Serial.println();
  58.   Serial.println(">>> EasyButton pressed example <<<");
  59.  
  60.   // Set pin mode with INPUT_PULLUP
  61.   pinMode(TFTrounddisplay_PushButton_PIN_D4, INPUT_PULLUP);  
  62.  
  63.   // Initialize the button
  64.   button.begin();  
  65.  
  66.   // Set the callback function for button press
  67.   button.onPressed(onPressed);  
  68. }
  69.  
  70. void loop(void)
  71. {
  72.   // Read the button state
  73.   button.read();  
  74. }
  75.  
  76. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement