Unit 4 Exercise 4-1 RGB Led Static Display
Unit 4 Exercise 4-1 RGB Led Static Display
_4__
Introduction:
RGB LEDs can produce different colors by mixing red, green, and blue light. Using an
Arduino, we can control these LEDs to change colors, adjust brightness, and create lighting
effects. This project focuses on learning how to program an Arduino to control RGB LEDs
using digital and PWM outputs. By understanding the basics of coding and circuit design, we
can create useful and creative lighting applications.
Learning Objectives:
1. Understand the principles of RGB LED control using Arduino – Learn how to program and
manipulate RGB LEDs to display different colors and lighting sequences.
3. Implement circuit design for LED sequencing – Learn how to wire and control multiple
LEDs using digital and PWM outputs from an Arduino microcontroller.
Learning Outcomes:
1. Demonstrate the ability to write and upload Arduino code for controlling RGB LEDs in
different sequences and brightness levels.
3. Apply knowledge of pulse-width modulation (PWM) and digital outputs to create dynamic
lighting effects with RGB LEDs.Apply knowledge of pulse-width modulation (PWM) and
digital outputs to create dynamic lighting effects with RGB LEDs.
Statement of Problem:
With the increasing use of smart lighting and programmable LED systems, understanding
how to control RGB LEDs using microcontrollers like Arduino has become an essential skill.
However, beginners often struggle with coding, wiring, and implementing complex LED
sequences. This study aims to bridge the gap by providing a step-by-step guide to
programming and controlling RGB LEDs using the Arduino platform. Through practical
exercises, learners will gain hands-on experience in circuit design, PWM control, and
sequential lighting effects, preparing them for real-world applications in automation,
decorative lighting, and embedded systems.
1
List of Materials:
1.Circuit Assembly – The RGB LEDs and resistors were connected to the Arduino board
according to the wiring diagram. Digital and PWM pins were used to control the LEDs.
2. Arduino Code Development – A program was written in the Arduino IDE to control the
LEDs. The code included different lighting sequences and brightness adjustments using
PWM.
//========== Initialization============
void setup()
2
digitalWrite(scan[i], 1); // disable scan outputs
void loop()
for(int i=0; i<8; i++) // display white, cyan, magenta, blue, yellow, green, red, black
// in sequence
digitalWrite(LED[j], color0[i*3+j]);
// #2: LEDs DS10A to DS10D light in red, green, blue, and white,
delay(2); // a delay of 2 ms
3
digitalWrite(scan[3-j], 1); // disable scan outputs
delay(2); // a delay of 2 ms
// #4: LEDs mixing color using PWM output and nested loops
for(int R=0; R<256; R+=15) // the outer for loop varies the brightness
for(int G=0; G<256; G+=15) // the middle for loop varies the brightness
for(int B=0; B<256; B+=15) // the inner for loop varies the brightness
digitalWrite(scan[i], 0);
delay(25); // a delay of 25 ms
digitalWrite(scan[i], 1);
4
}
3. Uploading and Testing – The code was compiled and uploaded to the Arduino board. The
LED behavior was observed to ensure correct color transitions and timing.
4.Troubleshooting and Debugging – If the LEDs did not function as expected, wiring
connections and code were checked and corrected. Adjustments were made to improve the
lighting effects.
5.Data Collection and Analysis – The LED responses were recorded for different code
modifications. Observations were analyzed to understand how changes in programming
affected the LED output.
The experiment successfully demonstrated how RGB LEDs can be controlled using an
Arduino. The LEDs displayed various colors and brightness levels as programmed. The
PWM function effectively adjusted brightness, and the sequential lighting effects worked as
expected. Minor issues such as incorrect wiring and code errors were resolved through
troubleshooting. The project confirmed that precise control of RGB LEDs could be achieved
using simple coding techniques.
This study successfully demonstrated how to control RGB LEDs using Arduino through
coding and circuit design. The LEDs responded accurately to programmed instructions,
displaying various colors and brightness levels using digital and PWM outputs. Sequential
lighting effects were achieved, though minor timing adjustments improved performance.
PWM control effectively adjusted brightness, and troubleshooting helped resolve initial
issues such as wiring errors and code syntax mistakes. Overall, the project provided a
hands-on understanding of Arduino-based LED control, serving as a foundation for future
applications in smart lighting and embedded systems.
5
Documentation:
6
7