[go: up one dir, main page]

0% found this document useful (0 votes)
50 views4 pages

ECE38RGB

The document discusses using an Arduino Uno to control an RGB LED with pulse-width modulation (PWM) output. It explains how to connect the RGB LED and use the analogWrite() function to set the PWM values for each color channel to produce different colors. It then provides procedures for programming color patterns and smooth color transitions using the RGB LED.

Uploaded by

Vanvan Biton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

ECE38RGB

The document discusses using an Arduino Uno to control an RGB LED with pulse-width modulation (PWM) output. It explains how to connect the RGB LED and use the analogWrite() function to set the PWM values for each color channel to produce different colors. It then provides procedures for programming color patterns and smooth color transitions using the RGB LED.

Uploaded by

Vanvan Biton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ECE-38: Microcontrollers-Lab

Task #8
Using Arduino with RGB LED (PWM output)

PWM output

The Arduino UNO has 14 digital input/output pins. There are a total of 6
pins that can be used as PWM outputs. These PWM output pins are pins #11, #10,
#9, #6, #5, and #3.

The PWM output can range from values 0 to 255, which can be used as a
voltage source than can range from 0 Volts to +5Volts.

PWM VALUE TABLE


The analogWrite(); Function

The instruction syntax to output a PWM signal is analogWrite(pin, duty cycle); where ‘pin’ is the pin number, and the
duty cycle is any integer from 0 to 255.

RGB color coding

In order to produce colors other than the standard RED, GREEN, and BLUE colors, each LED must be driven by
the correct voltage levels that are equivalent to the PWM values. In this activity, the standard notation that we will be
using is (R-G-B). For example, the following colors will have the respective notations:

BLUE = (0-0-250) → which means RED is 0%, GREEN is 0%, and BLUE is 100%.
MAGENTA = (250-0-250) → which means RED is 100%, GREEN is 0%, and BLUE is 100%.
ORANGE = (250-125-0) → which means RED is 100%, GREEN is 50%, and BLUE is 0%.

PROCEDURE #1
Use PWM output pins 9 to 11 to connect the RGB LED as shown in the
given figure. RED = pin #11, GREEN = pin #10, BLUE = pin #9. Connect.
220 ohm resistors to each LED pin to limit the current.

Create a program that will simulate a traffic light. At a tact switch that
will be used to transition to the next pattern color and loop back.

Color Pattern: GREEN-YELLOW-RED-YELLOW-GREEN


PROCEDURE #2 (30pts)
Based on the last 4-digits of your ID# and the digit-color code below, create a program that will
automatically display the corresponding distinct color pattern equivalent to your ID#.

Conditions:
a.) Each color must be on for 2.0 seconds.
b.) Display green at the start of the program. Display red at the end.
c.) Insert a 1.0 second delay where the LED will be off in between transitions.
d.) After the entire sequence put a 3-second LED off state before looping back at the start.

For example: ID# = 2020-3316a the color pattern will be:


3 = BLUE, 1 = MAGENTA, 6 = AQUAMARINE, therefore, the required pattern will be:
PROCEDURE #3 (40pts)
Smooth Color Transition Effect – 4 colors only
Based on the 4-colors assigned to you (ID# last 4-digit) create
an Arduino code that will display a smooth fade color transition
effect when changing between each of the 4 colors.

IMPORTANT:
1. Each designated color must stay ON for at least 2.0 seconds before transitioning.
2. Each transition effect must be completed within a 5.0 second period.
3. Transition colors to be used must be in the farthest direction based on the color-wheel.
Example: for BLUE to RED transition, use:

4. For same color transition, the effect must go around the color wheel displaying all colors.
Example #2: for RED to RED transition, use:

You might also like