/********* 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: Button Control
- Source Code compiled for: Arduino Uno
- Source Code created on: 2023-12-06 11:28:57
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* turns on and off bright orange */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t BUTTON_PIN = 2;
/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t GREEN_LED_PIN = 11;
const uint8_t RED_LED_PIN = 12;
/****** DEFINITION OF LIBRARY CLASS INSTANCES*****/
EasyButton button(BUTTON_PIN, true, false, 50);
void setup(void)
{
// put your setup code here, to run once:
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(RED_LED_PIN, OUTPUT);
button.begin();
}
void loop(void)
{
// put your main code here, to run repeatedly:
button.read();
// Add your code logic for button press event and LED control here
if (button.isPressed()) {
digitalWrite(GREEN_LED_PIN, HIGH); // Turn on the green LED
digitalWrite(RED_LED_PIN, LOW); // Turn off the red LED
} else {
digitalWrite(GREEN_LED_PIN, LOW); // Turn off the green LED
digitalWrite(RED_LED_PIN, HIGH); // Turn on the red LED
}
}