
Driving an RGB LED — SIK Circuit 3
Maagizo
Parts & Introduction
Parts & Introduction
An RGB LED contains three tiny LEDs (red, green, blue) in one package. By mixing different brightness levels of each color, you can create any color in the rainbow. This experiment introduces analogWrite() for PWM output.
Parts Needed
- 1x Arduino Uno + USB cable
- 1x Breadboard
- 1x RGB LED (Common Cathode)
- 3x 330Ω Resistors
- 5x Jumper Wires
RGB LED Pin Order (flat edge facing you): Red, Ground (longest pin), Green, Blue.
Vifaa kwa hatua hii:
SparkFun Inventor's Kit - V3.21 kifaaZana zinazohitajika:
Kompyuta yenye IDE ya ArduinoHardware Hookup
Hardware Hookup
Wiring Instructions
- Place the RGB LED in the breadboard. Identify pins from the flattened edge: Red, GND (longest), Green, Blue.
- Connect the GND pin (longest, second from left) to the GND rail.
- Connect the Red pin through a 330Ω resistor to Arduino Pin 9.
- Connect the Green pin through a 330Ω resistor to Arduino Pin 10.
- Connect the Blue pin through a 330Ω resistor to Arduino Pin 11.
Pins 9, 10, and 11 are all PWM-capable (marked with ~ on the board).
Vifaa kwa hatua hii:
Utepe wa LED wa RGB 5050 (usioelekezeka)1 kipande
Bao la Majaribio1 kipande
Nyaya za Kuunganisha5 vipandeArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
Vifaa kwa hatua hii:
Arduino Uno R31 kipandeZana zinazohitajika:
Kompyuta yenye IDE ya ArduinoTest & Experiment
Test & Experiment
What You Should See
The LED cycles through 8 solid colors (off, red, green, blue, yellow, cyan, purple, white) for 1 second each, then smoothly fades through the entire color spectrum.
Troubleshooting
- Incorrect colors: With four pins close together, it's easy to misplace one. Double-check each connection.
- Red too bright: The red diode is often brighter. Try a higher-value resistor on the red pin, or reduce in code:
analogWrite(RED_PIN, redIntensity/3).
Experiments to Try
- Add a potentiometer to control which color is displayed.
- Create your own color sequences — try a "sunrise" effect (dark red → orange → yellow → white).
Vifaa
6- SparkFun Inventor's Kit - V3.2Kamisheni 10%1 kifaa$105.94
- Kishikilia Nafasi
- kuanzia$9.50
- kuanzia$4.16
- kuanzia$27.06
- 3 vipandeKishikilia Nafasi
Zana Zinazohitajika
1- Kishikilia Nafasi
CC0 Umma Wote
Mchoro huu umetolewa chini ya CC0. Uko huru kunakili, kubadilisha, kusambaza, na kutumia kazi hii kwa madhumuni yoyote, bila kuomba ruhusa.
Saidia Mtengenezaji kwa kununua bidhaa kupitia Mchoro wao ambapo wanapata Kamisheni ya Mtengenezaji iliyowekwa na Wachuuzi, au unda marudio mapya ya Mchoro huu na uiunganishe kama kiungo katika Mchoro wako kuchangia mapato.