Project 1.5.7: RAINBOW COLOURS¶
Description | You will learn how to create a simple circuit and program three (3) LEDs to form a very decorative and multicolored system. |
---|---|
Use case | Having a nice house party at your house, you might not want to buy light decorations from outside. Out of this you can still use this approach to make the place much nicer. |
Components (Things You will need)¶
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
Building the circuit¶
Things Needed:
- Arduino Uno Board = 1
- Arduino USB cable = 1
- RGB= 1
- Red jumper wires = 1
- Green jumper wires = 1
- Brown jumper wires = 1
- Blue jumper wires = 1
Mounting the component on the breadboard¶
Step 1: The RGB module has four pins, R pin(red), G pin(green), B pin(blue) and – pin (GND). On the middle section of the breadboard, locate each horizontal section lettered A to J. Take the RGB module and insert it into any of the lettered section (Say A) horizontally. NB: Take note of where each of the pins of the RGB are placed on the bread board.
.
WIRING THE CIRCUIT¶
Things Needed:
- Red jumper wires = 1
- Green jumper wires = 1
- Brown jumper wires = 1
- Blue jumper wires = 1
Step 2: Take the Red male-to-male jumper wire and connect one end to the R pin of the RGB module and the other end to digital pin number 8 on the Arduino uno board.
.
Step 3: Take the Green male-to-male jumper wire and connect one end to the G pin of the RGB module and the other end to digital pin number 9 on the Arduino uno board.
.
Step 4: Take the Blue male-to-male jumper wire and connect one end to the B pin of the RGB module and the other end to digital pin number 10 on the Arduino uno board.
.
Step 5: Take the Brown male-to-male jumper wire and connect one end to the - pin of the RGB module and the other end to GND on the Arduino uno board.
.
NB: Connect the USB port of the Arduino cable to the USB port of your laptop and the other side of the Arduino cable to the Arduino Uno Board.
PROGRAMMING¶
Step 1: Open your Arduino IDE. See how to set up here: Getting Started.
Step 2: Type const int Red = 8;
as shown in the picture below. Replace “8” with the digital pin you allocated to the red pin of the RGB.
.
Step 3: Type const int Green = 9;
as shown in the picture below. Replace “9” with the digital pin you allocated to the green pin of the RGB.
.
Step 4: Type const int Blue = 10;
as shown in the picture below. Replace “10” with the digital pin you allocated to the blue pin of the RGB.
.
Step 5: Inside the (void setup ()) type pinMode (red, OUTPUT);
as shown in the picture below.
.
NB: pinMode will help the Arduino board to decide which port should be activated and OUTPUT because the RGB is an output device.
Step 6: type pinMode (green, OUTPUT);
as shown in the picture below.
.
Step 7: type pinMode (blue, OUTPUT);
as shown in the picture below.
.
Step 8: Go to the next line after the closing bracket for the area where you put your main code. Here a function will be declared so that the RGB can combine an amount of the three (3) colors to give out a unique color.
Step 9: Type
void Setcolor (int Red, int Green, int Blue) {
analogWrite (red, Red);
analogWrite (green, Green);
analogWrite (blue, Blue);
}
as shown in the picture below.
.
NB: The highest amount of each primary color of the RGB has a value of 255, we call the function Setcolor and apportion an amount of each of the primary colors to get a different color as demonstrated in the subsequent steps.
Step 10 :
- (Red): Type
Setcolor (255, 0, 0);
in the area for your main code as shown in the picture below.
.
- (Orange): Type Setcolor (255, 127, 0); in the area for your main code as shown in the picture below.
.
- (Yellow): Type Setcolor (255, 255, 0); in the area for your main code as shown in the picture below.
.
- (Green): Type Setcolor (0, 255, 0); in the area for your main code as shown in the picture below.
.
- (Blue): Type Setcolor (0, 0, 255); in the area for your main code as shown in the picture below.
.
- (Indigo): Type Setcolor (75, 0, 130); in the area for your main code as shown in the picture below.
.
- (Violet): Type Setcolor (148, 0, 211); in the area for your main code as shown in the picture below.
.
Step 11: We can introduce a delay after the code for each color, so the colors come right after each other.
- This is to keep the light on for a while (1000miliseconds = 1second), before the next color comes on.
Type:
Setcolor (255, 0, 0);
delay (100);
Setcolor (255, 127, 0);
delay (100);
Setcolor (255, 255, 0);
delay (100);
Setcolor (0, 255, 0);
delay (100);
Setcolor (0, 0, 255);
delay (100);
Setcolor (75, 0, 130);
delay (100);
Setcolor (148, 0, 211);
as shown in the picture below.
Step 12: Save your code. See the Getting Started section
Step 13: Select the arduino board and port See the Getting Started section:Selecting Arduino Board Type and Uploading your code.
Step 14: Upload your code. See the Getting Started section:Selecting Arduino Board Type and Uploading your code
CONCLUSION¶
To conclude, the RGB rainbow colors project offers an immersive exploration of color mixing and dynamic lighting effects. By manipulating the red, green, and blue components, participants gain insights into color theory, electronic control, and the art of visual representation. This endeavor serves as a creative foundation in electronics, illustrating the power of color variation and inspiring curiosity in practical applications, from decorative lighting to digital art installations.