Advertisement
pleasedontcode

EasyButton Library rev_01

May 13th, 2024
1,210
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 Library
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-13 13:49:55
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The device to be made is equipped with 7 LEDs and */
  21.     /* 3 buttons. At startup, all LEDs are off. The first */
  22.     /* button is used to increase the binary number by 1, */
  23.     /* the second to decrease the binary number by 1, and */
  24.     /* the third to display on the serial monitor the */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  35. const uint8_t btn_PushButton_PIN_D2 = 2;
  36.  
  37. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  38.  
  39. // Instance of the button
  40. EasyButton button(btn_PushButton_PIN_D2);
  41.  
  42. // Callback function to be called when the button is pressed
  43. void onPressed()
  44. {
  45.   Serial.println("Button pressed");
  46. }
  47.  
  48. void setup(void)
  49. {
  50.   // put your setup code here, to run once:
  51.   pinMode(btn_PushButton_PIN_D2, INPUT_PULLUP);
  52.  
  53.   // Initialize the button
  54.   button.begin();
  55.   // Add the callback function to be called when the button is pressed
  56.   button.onPressed(onPressed);
  57. }
  58.  
  59. void loop(void)
  60. {
  61.   // put your main code here, to run repeatedly:
  62.   button.read();
  63. }
  64.  
  65. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement