Advertisement
pleasedontcode

Button Actions rev_02

Oct 1st, 2024
83
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 Actions
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-10-01 20:58:40
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* code will be ina java script and code will allow */
  21.     /* us to auto answer question right and skip through */
  22.     /* videos this code is going to be the same as edgy */
  23.     /* pro */
  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. // Create instances of EasyButton for each button
  39. EasyButton button1(bottom_PushButton_PIN_D2); // Initialize button1 with pin D2
  40. EasyButton button2(bottom_PushButton_PIN_D3); // Initialize button2 with pin D3
  41.  
  42. // Function prototypes for button press events
  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 the serial monitor
  52.     Serial.println();
  53.     Serial.println(">>> EasyButton example <<<");
  54.  
  55.     // Initialize the buttons
  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 state of the buttons
  67.     button1.read();
  68.     button2.read();
  69. }
  70.  
  71. // Function to be called when button1 is pressed
  72. void onButton1Pressed() {
  73.     Serial.println("Button1 pressed");
  74.     // Add code here to auto answer questions or perform actions
  75.     // Example: autoAnswerQuestion();
  76. }
  77.  
  78. // Function to be called when button2 is pressed
  79. void onButton2Pressed() {
  80.     Serial.println("Button2 pressed");
  81.     // Add code here to skip through videos or perform actions
  82.     // Example: skipVideo();
  83. }
  84.  
  85. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement