Advertisement
pleasedontcode

Button Actions rev_01

Jan 13th, 2024
76
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 compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-13 10:45:03
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Turn on led using push button */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* Turn on led using push button */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27. #include <EasyButton.h>
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void onButtonD2Pressed();
  33. void onButtonD3Pressed();
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t Mybutton_PushButton_PIN_D2 = 2;
  37. const uint8_t Mybutton_PushButton_PIN_D3 = 3;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. EasyButton button_D2(Mybutton_PushButton_PIN_D2);
  41. EasyButton button_D3(Mybutton_PushButton_PIN_D3);
  42.  
  43. void setup(void)
  44. {
  45.   // put your setup code here, to run once:
  46.   pinMode(Mybutton_PushButton_PIN_D2, INPUT_PULLUP);
  47.   pinMode(Mybutton_PushButton_PIN_D3, INPUT_PULLUP);
  48.  
  49.   // Initialize button objects
  50.   button_D2.begin();
  51.   button_D3.begin();
  52.  
  53.   // Assign button press callbacks
  54.   button_D2.onPressed(onButtonD2Pressed);
  55.   button_D3.onPressed(onButtonD3Pressed);
  56. }
  57.  
  58. void loop(void)
  59. {
  60.   // put your main code here, to run repeatedly:
  61.   button_D2.read();
  62.   button_D3.read();
  63. }
  64.  
  65. void onButtonD2Pressed()
  66. {
  67.   // Turn on LED or perform any action for System Requirement 1
  68. }
  69.  
  70. void onButtonD3Pressed()
  71. {
  72.   // Turn on LED or perform any action for System Requirement 2
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement