Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Sastry_v1
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-11-11 23:54:18
- - Source Code generated by: M B G Sastry
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <EasyButton.h>
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Turn on and off a light when pushing a button */
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Mybutton_PushButton_PIN_D2 = 2;
- const uint8_t Mybutton_PushButton_PIN_D3 = 3;
- const uint8_t Mybutton_PushButton_PIN_D4 = 4;
- const uint8_t Mybutton_PushButton_PIN_D5 = 5;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t MyLED_PIN_D6 = 6;
- const uint8_t MyLED_PIN_D7 = 7;
- const uint8_t MyLED_PIN_D8 = 8;
- const uint8_t MyLED_PIN_D9 = 9;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button_D2(Mybutton_PushButton_PIN_D2);
- EasyButton button_D3(Mybutton_PushButton_PIN_D3);
- EasyButton button_D4(Mybutton_PushButton_PIN_D4);
- EasyButton button_D5(Mybutton_PushButton_PIN_D5);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(Mybutton_PushButton_PIN_D2, INPUT_PULLUP);
- pinMode(Mybutton_PushButton_PIN_D3, INPUT_PULLUP);
- pinMode(Mybutton_PushButton_PIN_D4, INPUT_PULLUP);
- pinMode(Mybutton_PushButton_PIN_D5, INPUT_PULLUP);
- pinMode(MyLED_PIN_D6, OUTPUT);
- pinMode(MyLED_PIN_D7, OUTPUT);
- pinMode(MyLED_PIN_D8, OUTPUT);
- pinMode(MyLED_PIN_D9, OUTPUT);
- button_D2.begin();
- button_D3.begin();
- button_D4.begin();
- button_D5.begin();
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- button_D2.read();
- button_D3.read();
- button_D4.read();
- button_D5.read();
- // Check button states and control LED accordingly
- if (button_D2.isPressed()) {
- digitalWrite(MyLED_PIN_D6, HIGH);
- } else {
- digitalWrite(MyLED_PIN_D6, LOW);
- }
- if (button_D3.isPressed()) {
- digitalWrite(MyLED_PIN_D7, HIGH);
- } else {
- digitalWrite(MyLED_PIN_D7, LOW);
- }
- if (button_D4.isPressed()) {
- digitalWrite(MyLED_PIN_D8, HIGH);
- } else {
- digitalWrite(MyLED_PIN_D8, LOW);
- }
- if (button_D5.isPressed()) {
- digitalWrite(MyLED_PIN_D9, HIGH);
- } else {
- digitalWrite(MyLED_PIN_D9, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement