
Driving an RGB LED — SIK Circuit 3
Зааварчилгаа
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.
Materials for this step:
SparkFun Inventors Kit - V3.21 багц
Arduino Uno R31 ширхэг
Breadboard1 ширхэг
RGB LED (Common Cathode)1 ширхэг
330 Ohm Resistor3 ширхэг
Jumper Wires5 ширхэгTools needed:
Hardware 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).
Materials for this step:
RGB LED (Common Cathode)1 ширхэг
330 Ohm Resistor3 ширхэг
Breadboard1 ширхэг
Jumper Wires5 ширхэгArduino Code
Arduino Code
Open the Arduino IDE and upload the following sketch to your Arduino board.
Materials for this step:
Arduino Uno R31 ширхэгTools needed:
Test & 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).
Материал
6- $105.00
- 1 ширхэгPlaceholder
- 1 ширхэгPlaceholder
- Placeholder
- $3.00
- $5.00
You can swap these in
Can't get one of the materials? Swap it for an equivalent — these work just as well.
- Instead of Arduino Uno R3, try:
Prototyping Shield for Arduino Uno (3-Pack)
Arduino Uno R3 Board
Arduino Uno - Instead of Resistor 330 Ohm 1/6 Watt PTH - 20 pack, try:
Resistor 10K Ohm 1/6th Watt PTH - 20 pack
AVR ISP Shield - PTH Kit
Resistor 1.0M Ohm 1/6th Watt PTH - 20 pack - Instead of Breadboard, try:
Solder-able Breadboard - Instead of LED - RGB Diffused Common Cathode - 5mm, try:
LED - RGB Clear Common Cathode - 5mm
Recommended for this build
Products makers often use with builds like this one.
5mm LED Assortment Kit (300pcs, 5 Colors)Used together and in similar builds
Resistor 10K Ohm 1/6th Watt PTH - 20 packFrequently used with this build's materials
Diode KitFrequently used with this build's materials
BC547 NPN Transistor (50-Pack)Frequently used with this build's materials
Push Button - 33mmFrequently used with this build's materials
Piezo ElementFrequently used with this build's materials
PotentiometerFrequently used with this build's materials
Servo MotorFrequently used with this build's materialsRelated blueprints
Other builds that share materials, tools, or techniques with this one.






CC0 Нийтийн домэйн
Энэ загвар CC0 дор гаргагдсан. Та зөвшөөрөл авахгүйгээр хуулах, өөрчлөх, түгээх, ашиглах боломжтой.
Загвараар дамжуулан бүтээгдэхүүн худалдаж авч Бүтээгчийг дэмжээрэй Бүтээгчийн шимтгэл Борлуулагчаар тогтоосон, эсвэл энэ загварын шинэ хувилбар үүсгэж орлогоо хуваахын тулд өөрийн загварт холбоос болгон оруулна уу.