RGB Module
RGB Module
Module 1 Lesson 4
Lesson 4: RGB Module
Target Outcomes
Engage
What is your
favorite color?
Lesson 4: RGB Module
Engage
Lesson 4: RGB Module
Explore
Data Collection for Poking Fun at Color Mixing
Explain
Explain
Explain
The intensity of the light produced by each LED can be controlled by adjusting the
value of intensity for each color. By mixing or adjusting the intensity this primary colors of
light almost all colors can be produced.
Lesson 4: RGB Module
Arduino Review
digitalWrite()
Description
Write a HIGH or a LOW value to a digital pin.
If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V
boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is
recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial for more
information.
If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when calling digitalWrite(HIGH), the LED may appear dim.
Without explicitly setting pinMode(), digitalWrite() will have enabled the internal pull-up resistor, which acts like a large current-limiting
resistor.
Syntax
digitalWrite(pin, value)
Parameters
pin: the Arduino pin number.
value: HIGH or LOW.
Lesson 4: RGB Module
Elaborate
Materials
Microcontroller USB Cable Jumper Wire
Breadboard 3 pc. 220 Ohms Resistors 1 pc. RGB Module
Procedure
1. Examine the RGB module prepared by your teacher.
2. Study the code that turns the RGB module light into RED.
Elaborate
RED
digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW);
delay(1000);
GREEN BLUE
digitalWrite(RED_PIN, LOW); digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, HIGH); digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW); digitalWrite(BLUE_PIN, HIGH);
delay(1000); delay(1000);
Lesson 4: RGB Module
Elaborate
YELLOW PURPLE
digitalWrite(RED_PIN, HIGH); digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, HIGH); digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW); digitalWrite(BLUE_PIN, HIGH);
delay(1000); delay(1000);
CYAN WHITE
digitalWrite(RED_PIN, LOW); digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH);
digitalWrite(BLUE_PIN, HIGH); digitalWrite(BLUE_PIN, HIGH);
delay(1000); delay(1000);
Lesson 4: RGB Module
Elaborate
3. Key in the code for each color using your RGB module.
Evaluate
1. Manipulate your RGB module and determine the code to produce RED, BLUE and
GREEN colors with different levels of brightness.
2. Complete the table by supplying the missing code for each level of brightness.
3. Answer the question: How will you set up the color intensity of your RGB module? (Type
in the specific value for each color).
Lesson 4: RGB Module
Additional Assessment
Using the RGB LED, use these following RGB codes to program the microcontroller
to see what color that was programmed:
Using the RGB LED, use these following RGB codes to program the microcontroller
to see what color that was programmed: