0% found this document useful (0 votes)
36 views7 pages

Unit 4 Exercise 4-1 RGB Led Static Display

The document outlines a laboratory activity focused on controlling RGB LEDs using an Arduino, emphasizing programming skills and circuit design. It includes objectives, methodology, and results demonstrating successful LED control through coding and PWM techniques. The project serves as a practical introduction to smart lighting applications and embedded systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views7 pages

Unit 4 Exercise 4-1 RGB Led Static Display

The document outlines a laboratory activity focused on controlling RGB LEDs using an Arduino, emphasizing programming skills and circuit design. It includes objectives, methodology, and results demonstrating successful LED control through coding and PWM techniques. The project serves as a practical introduction to smart lighting applications and embedded systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Auto_228_Laboratory Activity No.

_4__

Name of Activity: RBG LED STATIC DISPLAY

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.

2. Develop programming skills in Arduino IDE – Gain hands-on experience in writing,


compiling, and uploading Arduino sketches for LED control.

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. Successfully construct and troubleshoot an Arduino-based LED circuit following a given


wiring diagram.Successfully construct and troubleshoot an Arduino-based LED circuit
following a given wiring diagram.

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. Tutor for Arduino MTS -101


2. Arduino Kit (Jumper Wires)
3. Desktop Computer
4. USB Cord
5. AC Power Cord
6. Arduino Uno Trainer
Methodology:

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.

Heres the code:

//========== ex4-11.ino ============

// RGB LED com pins connected to pins 7, 6, 5, 4

// RGB LED pins R, G, B connected to pins 10, 9, 11

//========== Global Declaration ============

const int scan[]={4,5,6,7}; // scan outputs connected to digital pins 4-7

const int LED[]={11,9,10}; // color outputs connected to digital pins 9-11

const int color0[][3]= // declare a basic color array (BGR)

{ 0,0,0, 0,0,1, 0,1,0, 0,1,1, 1,0,0, 1,0,1, 1,1,0, 1,1,1 };

const int color1[]= // declare a mixing color array (BGR)

{ 1,1,0, 1,0,1, 0,1,1, 0,0,0, 0,0,1, 0,1,0, 1,0,0, 1,1,1 };

//========== Initialization============

void setup()

{ for(int i=0; i<4;i++)

{ pinMode(scan[i], OUTPUT); // configure digital pins 4-7 as outputs

2
digitalWrite(scan[i], 1); // disable scan outputs

for(int i=0; i<3; i++)

{ pinMode(LED[i], OUTPUT); // configure digital pins 9-11 as outputs

digitalWrite(LED[i], 1); // disable color outputs

//========== Main Code ============

void loop()

{ // #1: 4 LEDs sequentially display a single color listed in Table 4-1,

// with max brightness, non-scanning, 1 second each

for(int i=0; i<8; i++) // display white, cyan, magenta, blue, yellow, green, red, black

// in sequence

{ for(int j=0; j<3; j++) // fill color

digitalWrite(LED[j], color0[i*3+j]);

for(int j=0;j<4; j++) digitalWrite(scan[j], 0); // enable scan outputs

delay(1000); // a delay of 1 second

for(int j=0;j<4; j++) digitalWrite(scan[j], 1); // disable scan outputs

// #2: LEDs DS10A to DS10D light in red, green, blue, and white,

// (scan mode) respectively, for 1 second

for(int i=0; i<125; i++) // repeat 125 times, about 8*125=1000 ms

for(int j=0; j<4; j++) // scan 4 RGB LEDs

{ for(int k=0; k<3; k++) // fill color

digitalWrite(LED[k], color1[3*j + k]);

digitalWrite(scan[3-j], 0); // enable scan outputs

delay(2); // a delay of 2 ms

3
digitalWrite(scan[3-j], 1); // disable scan outputs

// #3: LEDs DS10A to DS10D light in cyan, magenta, yellow, black

// (scan mode) respectively, for 1 second

for(int i=0; i<125; i++) // repeat 125 times, about 8*125=1000 ms

for(int j=0; j<4; j++) // scan 4 RGB LEDs

{ for(int k=0; k<3; k++) // fill color

digitalWrite(LED[k], color1[12 + 3*j + k]);

digitalWrite(scan[3-j], 0); // enable scan outputs

delay(2); // a delay of 2 ms

digitalWrite(scan[3-j], 1); // disable scan outputs

// #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

// levels of red 0~255 in increments of 15

{ analogWrite(LED[2], R); // light red LEDs (fill red color)

for(int G=0; G<256; G+=15) // the middle for loop varies the brightness

// levels of green 0-255 in increments of 15

{ analogWrite(LED[1], G); // light green LEDs (fill green color)

for(int B=0; B<256; B+=15) // the inner for loop varies the brightness

// levels of blue 0-255 in increments of 15

{ analogWrite(LED[0], B); // light blue LEDs (fill blue color)

for(int i=0; i<4; i++) // enable scan outputs

digitalWrite(scan[i], 0);

delay(25); // a delay of 25 ms

for(int i=0; i<4; i++) // disable scan outputs

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.

Results and Findings:

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.

Conclusion and Observation:

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

You might also like