ArduinoStudio

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

A common-cathode RGB LED: red, green and blue legs on pins 9, 10 and 11, each through its own 220 Ω resistor, and the longest leg to GND.Arduino pin 9 to a 220 Ω resistor, then RGB LED red leg; Arduino pin 10 to a 220 Ω resistor, then RGB LED green leg; Arduino pin 11 to a 220 Ω resistor, then RGB LED blue leg; Arduino GND to RGB LED longest leg (cathode).Arduino Uno91011GNDRGB LEDcommon cathode, 4 legsred leggreen legblue leglongest leg (cathode)220 Ω220 Ω220 Ω
A common-cathode RGB LED: red, green and blue legs on pins 9, 10 and 11, each through its own 220 Ω resistor, and the longest leg to GND. Wire colours: blue for digital signals, grey dashed for ground.
FromThroughTo
Arduino pin 9220 Ω resistorRGB LED red leg
Arduino pin 10220 Ω resistorRGB LED green leg
Arduino pin 11220 Ω resistorRGB 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

SettingNew block starts atIn the settings panel
Red pin9Editable
Green pin10Editable
Blue pin11Editable
On/OffoffEditable
Color#ff0000Editable

Step by step

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. Press Play

    With the Bridge connected, the LED shows red, green, blue, and repeats until you press Stop.

  8. 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.

  1. Green

    Add an RGB block, on, Color #00ff00, then Wait 4000 ms.

  2. 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.

  3. Red

    Add an RGB block, on, Color #ff0000, then Wait 4000 ms.

  4. 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.

See the editor in action with a guided demo, no account or install needed: open the demo