Advertisement
pleasedontcode

Button Control rev_01

Jan 16th, 2024
65
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 Control
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-16 12:32:35
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn off and on light  every type of line just */
  21.     /* follow */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Arduino.h>
  26. #include <EasyButton.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup();
  30. void loop();
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t g_PushButton_PIN_D2 = 2;
  34. const uint8_t g_PushButton_PIN_D3 = 3;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  37. EasyButton button1(g_PushButton_PIN_D2);
  38. EasyButton button2(g_PushButton_PIN_D3);
  39.  
  40. void setup()
  41. {
  42.   // put your setup code here, to run once:
  43.   pinMode(g_PushButton_PIN_D2, INPUT_PULLUP);
  44.   pinMode(g_PushButton_PIN_D3, INPUT_PULLUP);
  45.  
  46.   button1.begin();
  47.   button2.begin();
  48. }
  49.  
  50. void loop()
  51. {
  52.   // put your main code here, to run repeatedly:
  53.   button1.read();
  54.   button2.read();
  55.  
  56.   // System Requirement 1: Turn off and on light for every type of line just follow
  57.   if (button1.isPressed())
  58.   {
  59.     // Code to turn on the light
  60.   }
  61.   else if (button2.isPressed())
  62.   {
  63.     // Code to turn off the light
  64.   }
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement