RGB LED
Mix red, green and blue in one LED and pick its colour with the RGB block.
An RGB LED holds a red, a green and a blue LED in one case. Drive each one with a PWM pin and you can mix almost any colour. In ArduinoStudio you place an RGB block, switch it on and pick a Color.
On a real board the RGB block runs only through the ArduinoStudio Bridge desktop app today. USB direct can’t run it yet, and the simulator can check your timing but can’t show the colour.
Wiring
| From | Through | To |
|---|---|---|
| Arduino pin 9 | 220 Ω resistor | RGB LED red leg |
| Arduino pin 10 | 220 Ω resistor | RGB LED green leg |
| Arduino pin 11 | 220 Ω resistor | RGB LED blue leg |
| Arduino GND | — | RGB LED longest leg (cathode) |
Give each colour leg its own 220 Ω resistor. If the same project also moves a servo, use pins 3, 5 and 6 instead: on an Uno, a running servo stops PWM on pins 9 and 10.
Block settings
| Setting | New block starts at | In the settings panel |
|---|---|---|
| Red pin | 9 | Editable |
| Green pin | 10 | Editable |
| Blue pin | 11 | Editable |
| On/Off | off | Editable |
| Color | #ff0000 | Editable |
Step by step
- Install and start the Bridge
Get the ArduinoStudio Bridge from the download page and start it. On a real board, colour runs only through the Bridge today.
- Wire the LED
Longest leg to GND. Red, green and blue legs each through a 220 Ω resistor to pins 9, 10 and 11. Plug the Uno into USB.
- Disconnect USB direct
If this tab is already connected with USB direct, click USB direct in the toolbar and press Disconnect on that row. USB direct can’t run the RGB block, and the Bridge needs the board’s port to itself.
- Connect through the Bridge
Click the connect button in the toolbar and press Connect on the Browser-agnostic — for Firefox/Safari/etc. row. That row is the Bridge. Follow the setup until the board shows as ready.
- Add an RGB block
Click + on the sequence, open the Components tab, open LED and choose RGB. Red pin 9, Green pin 10 and Blue pin 11 are the defaults. New RGB blocks start off, so switch On/Off to on. Color appears once the block is on; check that it reads #ff0000.
- Build the colour cycle
Add Wait 1000 ms, RGB (on, Color #00ff00), Wait 1000 ms, RGB (on, Color #0000ff), Wait 1000 ms. Then right-click the sequence name (long-press on a touchscreen) and tick Infinity Loop.
- Press Play
With the Bridge connected, the LED shows red, green, blue, and repeats until you press Stop.
- Try it without hardware
Choose Simulate without hardware to run the sequence on screen. Each block shows ON and its hex code, but the Virtual Board shows pins 9, 10 and 11 all at 1. Use it to check timing, not colour.
Mini-project: one-LED traffic light
Turn one RGB LED into a traffic light. Keep the same wiring and the Bridge connection. For a version with three separate LEDs, see the standard LED guide or the traffic light project idea.
- Green
Add an RGB block, on, Color #00ff00, then Wait 4000 ms.
- Amber
Add an RGB block, on, Color #ffbf00, then Wait 1000 ms. Amber is full red plus some green. If yours looks too yellow, lower the middle two hex digits.
- Red
Add an RGB block, on, Color #ff0000, then Wait 4000 ms.
- Loop it
Tick Infinity Loop on the sequence and press Play.
Without Infinity Loop, end the sequence with an RGB block whose On/Off is off, so the LED doesn’t stay red.
Questions
Why won’t the RGB block run when I connect with USB direct?
The install-free USB direct connection doesn’t support the RGB block yet. Play shows “USB direct does not support RGB yet” and doesn’t run it over USB. To light real colours, run the ArduinoStudio Bridge desktop app and connect the board through it, or use Simulate without hardware to check timing.
I picked a colour but the LED stays dark. What’s missing?
Check the block’s On/Off switch. New RGB blocks start off, and a block that’s off turns all three pins off whatever Color says. Then confirm that the longest leg goes to GND and that each colour leg has its own resistor.
My colours come out wrong: red looks cyan. Why?
You probably have a common-anode LED, whose longest leg goes to 5V instead of GND. The Bridge drives the pins for a common-cathode LED, so every colour comes out inverted. Use a common-cathode LED, or pick the opposite colour: #00ffff shows red on a common-anode LED.
Can I preview the colour in the simulator?
Not yet. The simulator shows each RGB block as on or off, with its hex code as text, and the Virtual Board shows all three pins fully on. Colour only appears on a real LED through the Bridge.
Which Arduino pins can drive an RGB LED?
Pins that support PWM, so each colour can be mixed: 3, 5, 6, 9, 10 and 11 on an Uno. The block’s defaults are 9, 10 and 11. If the same project moves a servo, use 3, 5 and 6, because on an Uno a servo stops pins 9 and 10 from mixing colours.