All tutorials

3 · Outputs & actuators

RGB LED: mixing colours

Intermediate20 min

Goal

Create any colour with three PWM channels.

Why it matters

Additive red/green/blue synthesis is the principle behind every screen.

Steps

  1. 01Wire R, G, B to three PWM pins (9, 10, 11).
  2. 02Write a setColor(r, g, b) function.
  3. 03Cycle red, green, blue, yellow, cyan, magenta, white.

This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.

Next tutorials