Guided physical computing, beginning with the Arduino Starter Kit Classroom Pack

Arduino Uno R3

Mix color with an RGB LED

Control the red, green, and blue channels independently, then mix repeatable colors with PWM values.

CSTA 2026 mapping candidatesNot reviewed by CSTA
MS-PRO-VD-16ProgrammingMS-PRO-TR-19Programming

Students will

  • Identify the shared and individual RGB LED leads
  • Protect each color channel with its own resistor
  • Use three PWM values to create and document mixed colors

Evidence of success

  • Each channel lights independently through its own resistor
  • Three recorded PWM recipes produce distinguishable colors
  • The student can explain why common-anode hardware requires inverted output values

Hardware

  • Arduino Uno R3
  • Starter Kit RGB LED
  • Three 220 Ω resistors
  • Breadboard and jumper wires
  • Transparent color gels for comparison

Prerequisites

  • Build a protected LED output
  • Identify PWM-capable pins
  • Read the exact RGB LED lead arrangement

Before class

  • Verify the actual RGB LED pin order and whether its common lead is cathode or anode
  • Prepare a known-good three-resistor circuit
  • Explain that this sketch assumes a common-cathode LED and must be inverted for common-anode hardware

Reviewed connection map

Three protected color channels

D9 / D10 / D11PWM-capable red, green, and blue outputs
3 × 220 ΩOne resistor for each color channel
RGB LEDVerify channel order and common-lead type
GND or 5VCommon lead depends on the verified LED type
  1. Connect each color lead through its own resistor to the matching program pin.
  2. Connect the common lead only after verifying whether the supplied LED is common-cathode or common-anode.

Build and test

  1. 01Identify the RGB LED common lead and the red, green, and blue channel leads
  2. 02With power disconnected, connect each color channel through its own 220 Ω resistor to D9, D10, and D11
  3. 03Connect the verified common cathode to GND; stop and adapt the circuit and sketch if the actual part is common anode
  4. 04Test red, green, and blue independently before mixing them
  5. 05Record three PWM recipes and compare the emitted colors with the kit gels

Read before uploading

Annotated Arduino sketch

const int RED_PIN = 9;
const int GREEN_PIN = 10;
const int BLUE_PIN = 11;

void setColor(int red, int green, int blue) {
  analogWrite(RED_PIN, constrain(red, 0, 255));
  analogWrite(GREEN_PIN, constrain(green, 0, 255));
  analogWrite(BLUE_PIN, constrain(blue, 0, 255));
}

void setup() {
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
}

void loop() {
  setColor(255, 0, 0);
  delay(800);
  setColor(0, 255, 0);
  delay(800);
  setColor(0, 0, 255);
  delay(800);
  setColor(120, 30, 180);
  delay(800);
}

Optional engineering record

Record evidence from this lesson

Choose the prompts that help students explain predictions, evidence, debugging, and transfer. Saving creates a new entry in this browser’s Rudi notebook.

Record your thinking — optional4 prompts

Use these prompts if they help students capture evidence, decisions, or questions. You do not need to complete every prompt or create an entry at every step.

Nothing is saved until you choose this button.

Troubleshooting

One color never appears

Disconnect power and verify that channel's lead, resistor, breadboard row, and matching PWM pin.

Colors are inverted or the LED will not turn fully off

Verify whether the actual LED is common cathode or common anode and adapt both the shared connection and PWM values.

2026 middle school standards

Potential CSTA connections

Not reviewed by CSTA

These are evidence-based crosswalk candidates for curriculum review—not a claim of official alignment.

MS-PRO-VD-16

Use variables of multiple data types to store, access, and manipulate data within a program.

Students manipulate three integer channel values to create and compare color outputs.

Lesson evidence: Three documented PWM recipes
MS-PRO-TR-19

Use systematic strategies to test, refine, and document changes to a computing technology to meet the intended purpose.

Students isolate variables, compare observed behavior with the intended purpose, and document a revision.

Lesson evidence: Independent-channel and mixed-color test
View the official 2026 CSTA standardsStandard text: Computer Science Teachers Association (2026), CC BY-NC-SA 4.0.

Supporting concepts

ohms-law · power-and-signals · sketch-foundations

Sources and review

Arduino Uno R3 documentationArduino Projects Book · CC BY-NC-SA 3.0Arduino Fade example

Starting point, not verified curriculum. Review the actual hardware, circuit, code, power requirements, and classroom conditions.

After teaching this lesson

Make one bounded change—or connect the skill to a project.