Led Lighting Project.
Run and off red, blue and green LED sequentially |
In This Project, We Will Flash Three Red And Blue And Green Leds Sequentially.
Parts Required:
Red, Blue, Green LEDs
3 × 220 Ω Resistance
Battery 9V Holder
Connection Wires Male
Battery 9V
Arduino
Breadboard
USB Cable
You Can Buy These Pieces From Here LCSC
How It Works:
An Led Emits Light When A Small Current Is Passed Through It. LEDs Are Polarized, Which Means One Side Is Positive And One Side Is Negative. This Is Because The Led Will Work Only With Current Flowing In One Direction, From Positive To Negative. The Longer Leg Of The Led Is Positive And Must Connect To A Positive Power Connection. The Arduino Sketch Controls The Sequence Of Flashes.
LEDs Are Delicate Parts, Requiring Only A Small Amount Of Voltage To Light Up—Smaller Than The Voltage The Arduino Provides. To Prevent The Leds From Being Overloaded With Voltage And Burning Out, We Use Resistors, Which Limit The Amount Of Voltage Passing Through Them To The Led On The Other End.
You Can Change The Color Of Your LEDs And Use This Light Bar To Decorate A Car, Scooter, Bike, Picture Frame, Subwoofer, Or Almost Anything Else You Choose.
The Build:
Schematic:
Breadboard:
The Sketch:
/*
Run and off red, blue and green LED sequentially
www.electronicbo.com/
This example code is in the public domain.
Modified 7 July 2019
By electronic bo
*/
//Definition of variables and connected with output numbers
int red = 1; // red connected to digital pin 1
int blue = 2; // blue connected to digital pin 2
int green = 3;// green connected to digital pin 3
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(red, OUTPUT); // initialize red as an output.
pinMode(blue, OUTPUT); // initialize blue as an output.
pinMode(green, OUTPUT);// initialize green as an output.
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(red, HIGH); // turn the red LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(red, LOW); // turn the red LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(blue, HIGH); // turn the blueLED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(blue, LOW); // turn the blueLED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(green, HIGH);// turn the green LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(green, LOW); // turn the green LED off by making the voltage LOW
delay(1000); // wait for a second
}