Advertisement
pleasedontcode

Button Configuration rev_195

Jan 14th, 2024
71
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 Configuration
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-01-14 16:26:02
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* if button is pressed so set out to 128. */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <Arduino.h>
  25. #include <EasyButton.h>
  26.  
  27. /****** FUNCTION PROTOTYPES *****/
  28. void setup(void);
  29. void loop(void);
  30.  
  31. /****** SYSTEM REQUIREMENTS *****/
  32. /****** SYSTEM REQUIREMENT 1 *****/
  33.   /* if button is pressed so set out to 128. */
  34. const uint8_t out_PIN_D25 = 25;
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t butt_PushButton_PIN_D4 = 4;
  38.  
  39. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  40. EasyButton button(butt_PushButton_PIN_D4);
  41.  
  42. void setup(void)
  43. {
  44.   pinMode(butt_PushButton_PIN_D4, INPUT_PULLUP);
  45.   pinMode(out_PIN_D25, OUTPUT);
  46.  
  47.   Serial.begin(115200);
  48.   Serial.println(">>> EasyButton Example <<<");
  49.  
  50.   button.begin();
  51. }
  52.  
  53. void loop(void)
  54. {
  55.   button.read();
  56.  
  57.   if (button.isPressed())
  58.   {
  59.     analogWrite(out_PIN_D25, 128);
  60.   }
  61.   else
  62.   {
  63.     analogWrite(out_PIN_D25, 0);
  64.   }
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement