Fun Arduino Project: LED Lights Show!

Are you ready to brighten up your day with a fun Arduino project?

Do you want to learn how to create a light show with LED lights using an Arduino board?

Want to know how to control the LED lights with a button press?

Let's dive into the world of Arduino LED lights!

If you're looking to add a spark of creativity to your day, creating a LED lights show with Arduino is the perfect way to do it. With just a few simple components and some coding, you can bring your project to life!

Arduino is a versatile platform for creating interactive projects, and controlling LED lights is just one of the many possibilities. By using the Arduino programming language and libraries, you can easily control the behavior of LED lights based on input from a button.

To achieve the desired functionality of turning on a red LED and off a yellow LED when a button is pushed, and turning off a green LED after the button has been pushed and released 3 times, you will need to follow a specific code structure.

Here is a code snippet to help you achieve this LED lights show:

const int buttonPin = 4;
const int greenLEDPin = 3;
const int redLEDPin = 7;
const int yellowLEDPin = 9;
int buttonState = HIGH;
int prevButtonState = HIGH;
int buttonPressCount = 0;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(greenLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
pinMode(yellowLEDPin, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW && prevButtonState == HIGH) {
buttonPressCount++;
digitalWrite(redLEDPin, HIGH);
digitalWrite(yellowLEDPin, LOW);
}
prevButtonState = buttonState;
if (buttonPressCount >= 3) {
digitalWrite(greenLEDPin, LOW);
digitalWrite(redLEDPin, LOW);
}
}

By following this code structure and wiring the components correctly, you can create your very own LED lights show that responds to button presses. Get ready to impress your friends and family with your creative Arduino project!

← Exciting facts about space exploration Reflecting on the importance of achievable goals in kpis →