Advertisement
pleasedontcode

EasyButton Library rev_02

May 6th, 2024
791
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 compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-06 18:53:23
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* volume controller for Windows with 3 buttons */
  21.     /* (previous track, start/pause track, next track) */
  22.     /* and 4 potenciometers (master volume, volume of */
  23.     /* opera.exe) */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  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 BUTTON_ONE_PIN = 2;
  36. const uint8_t BUTTON_TWO_PIN = 4;
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. EasyButton button1(BUTTON_ONE_PIN);
  40. EasyButton button2(BUTTON_TWO_PIN);
  41.  
  42. void onButton1Pressed() {
  43.   Serial.println("Button1 pressed");
  44. }
  45.  
  46. void onButton2Pressed() {
  47.   Serial.println("Button2 pressed");
  48. }
  49.  
  50. void setup(void)
  51. {
  52.   // put your setup code here, to run once:
  53.   pinMode(BUTTON_ONE_PIN, INPUT_PULLUP);
  54.   pinMode(BUTTON_TWO_PIN, INPUT_PULLUP);
  55.  
  56.   Serial.begin(115200);
  57.   Serial.println();
  58.   Serial.println(">>> EasyButton multiple buttons example <<<");
  59.  
  60.   button1.begin();
  61.   button2.begin();
  62.   button1.onPressed(onButton1Pressed);
  63.   button2.onPressed(onButton2Pressed);
  64. }
  65.  
  66. void loop(void)
  67. {
  68.   // put your main code here, to run repeatedly:
  69.   button1.read();
  70.   button2.read();
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement