Advertisement
pleasedontcode

Sastry_v1 rev_01

Nov 11th, 2023
101
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: Sastry_v1
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-11 23:54:18
  15.     - Source Code generated by: M B G Sastry
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* Turn on and off a light when pushing a button */
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  30. const uint8_t Mybutton_PushButton_PIN_D2 = 2;
  31. const uint8_t Mybutton_PushButton_PIN_D3 = 3;
  32. const uint8_t Mybutton_PushButton_PIN_D4 = 4;
  33. const uint8_t Mybutton_PushButton_PIN_D5 = 5;
  34.  
  35. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  36. const uint8_t MyLED_PIN_D6 = 6;
  37. const uint8_t MyLED_PIN_D7 = 7;
  38. const uint8_t MyLED_PIN_D8 = 8;
  39. const uint8_t MyLED_PIN_D9 = 9;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. EasyButton button_D2(Mybutton_PushButton_PIN_D2);
  43. EasyButton button_D3(Mybutton_PushButton_PIN_D3);
  44. EasyButton button_D4(Mybutton_PushButton_PIN_D4);
  45. EasyButton button_D5(Mybutton_PushButton_PIN_D5);
  46.  
  47. void setup(void)
  48. {
  49.   // put your setup code here, to run once:
  50.   pinMode(Mybutton_PushButton_PIN_D2, INPUT_PULLUP);
  51.   pinMode(Mybutton_PushButton_PIN_D3, INPUT_PULLUP);
  52.   pinMode(Mybutton_PushButton_PIN_D4, INPUT_PULLUP);
  53.   pinMode(Mybutton_PushButton_PIN_D5, INPUT_PULLUP);
  54.   pinMode(MyLED_PIN_D6, OUTPUT);
  55.   pinMode(MyLED_PIN_D7, OUTPUT);
  56.   pinMode(MyLED_PIN_D8, OUTPUT);
  57.   pinMode(MyLED_PIN_D9, OUTPUT);
  58.  
  59.   button_D2.begin();
  60.   button_D3.begin();
  61.   button_D4.begin();
  62.   button_D5.begin();
  63. }
  64.  
  65. void loop(void)
  66. {
  67.   // put your main code here, to run repeatedly:
  68.   button_D2.read();
  69.   button_D3.read();
  70.   button_D4.read();
  71.   button_D5.read();
  72.  
  73.   // Check button states and control LED accordingly
  74.   if (button_D2.isPressed()) {
  75.     digitalWrite(MyLED_PIN_D6, HIGH);
  76.   } else {
  77.     digitalWrite(MyLED_PIN_D6, LOW);
  78.   }
  79.  
  80.   if (button_D3.isPressed()) {
  81.     digitalWrite(MyLED_PIN_D7, HIGH);
  82.   } else {
  83.     digitalWrite(MyLED_PIN_D7, LOW);
  84.   }
  85.  
  86.   if (button_D4.isPressed()) {
  87.     digitalWrite(MyLED_PIN_D8, HIGH);
  88.   } else {
  89.     digitalWrite(MyLED_PIN_D8, LOW);
  90.   }
  91.  
  92.   if (button_D5.isPressed()) {
  93.     digitalWrite(MyLED_PIN_D9, HIGH);
  94.   } else {
  95.     digitalWrite(MyLED_PIN_D9, LOW);
  96.   }
  97. }
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement