Advertisement
pleasedontcode

Example rev_03

Nov 29th, 2023
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: Example
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-29 19:06:39
  15.     - Source Code generated by: Francesco
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* Give me an example of usage of the button */
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  30. const uint8_t BUTTON_PIN = 2;
  31.  
  32. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  33. EasyButton button(BUTTON_PIN);
  34.  
  35. void setup(void)
  36. {
  37.   // put your setup code here, to run once:
  38.   Serial.begin(115200);
  39.   Serial.println();
  40.   Serial.println(">>> EasyButton pressed example <<<");
  41.  
  42.   // Set the button pin as input with internal pull-up resistor enabled
  43.   pinMode(BUTTON_PIN, INPUT_PULLUP);
  44.  
  45.   // Initialize the button object
  46.   button.begin();
  47.   button.onPressed([]() {
  48.     // Button is pressed, perform the desired action
  49.     Serial.println("Button pressed");
  50.   });
  51. }
  52.  
  53. void loop(void)
  54. {
  55.   // put your main code here, to run repeatedly:
  56.  
  57.   // Update the button state
  58.   button.update();
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement