Advertisement
pleasedontcode

EasyButton Handling rev_01

Oct 1st, 2024
84
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: EasyButton Handling
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-10-01 20:53:30
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* code is going answer questions automatically */
  21.     /* though edgeunity  as well as skip through videos */
  22.     /* which will be able to see through the menu and the */
  23.     /* code has to run though tamper monkey */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <EasyButton.h> // https://github.com/evert-arias/EasyButton
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  34. const uint8_t bottom_PushButton_PIN_D2 = 2; // Pin for Button 1
  35. const uint8_t bottom_PushButton_PIN_D3 = 3; // Pin for Button 2
  36.  
  37. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  38. // Instantiate EasyButton objects for each button using the defined pin numbers
  39. EasyButton button1(bottom_PushButton_PIN_D2); // Button on pin D2
  40. EasyButton button2(bottom_PushButton_PIN_D3); // Button on pin D3
  41.  
  42. // Function prototypes for button press handlers
  43. void onButton1Pressed();
  44. void onButton2Pressed();
  45.  
  46. void setup(void)
  47. {
  48.     // Initialize serial communication for debugging
  49.     Serial.begin(115200);
  50.    
  51.     // Print a message to indicate setup is starting
  52.     Serial.println();
  53.     Serial.println(">>> EasyButton example <<<");
  54.  
  55.     // Initialize the button instances
  56.     button1.begin();
  57.     button2.begin();
  58.  
  59.     // Set up the button press event handlers
  60.     button1.onPressed(onButton1Pressed);
  61.     button2.onPressed(onButton2Pressed);
  62. }
  63.  
  64. void loop(void)
  65. {
  66.     // Read the button states
  67.     button1.read();
  68.     button2.read();
  69. }
  70.  
  71. // Function to handle button 1 press event
  72. void onButton1Pressed() {
  73.     Serial.println("Button 1 pressed");
  74.     // Functionality to answer questions automatically
  75.     // This could be a call to a function that interacts with EdgeUnity or TamperMonkey
  76. }
  77.  
  78. // Function to handle button 2 press event
  79. void onButton2Pressed() {
  80.     Serial.println("Button 2 pressed");
  81.     // Functionality to skip through videos or navigate menus
  82.     // This could be a call to a function that interacts with EdgeUnity or TamperMonkey
  83. }
  84.  
  85. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement