Chapter 2: Solar Array Repair

Day 08: Adding some color to this dark place

Video lesson · 30 min

The darkness is oppressive — time to add color. Wire up an RGB LED and learn to mix red, green, and blue light to create any color. Understand PWM (Pulse Width Modulation) and analog output to control brightness and hue.

Mission Log: Day 8

The ship's emergency lighting has been failing for days now, leaving you in an oppressive darkness that seems to press against your very soul. The stark white maintenance lights flicker sporadically, casting eerie shadows that dance across the cramped corridors like ghosts of your former crewmates.

But today, something remarkable catches your eye in the supply compartment — a small, translucent dome no bigger than your thumbnail, with four delicate metal legs extending like the limbs of a mechanical spider. This isn't just any LED. The label reads "RGB LED" and suddenly, a spark of hope ignites in your chest.

You remember the training simulations back on Earth — how the old engineers used to say that light wasn't just illumination, it was life itself. Red, green, and blue — the three primaries that could paint any color across the spectrum. In your hands, you hold the power to bring the rainbow back to this cold, metallic tomb.

The HERO Board hums quietly, waiting for your commands. You can almost taste the anticipation — soon, this dreary spacecraft will pulse with colors you haven't seen since leaving Earth's atmosphere. The monotonous beeping of life support systems suddenly feels less oppressive. Today, you're not just surviving. Today, you're creating beauty in the darkness of space.

What You'll Learn

When you complete this mission, you'll be able to:

  • Control an RGB LED to create any color in the visible spectrum
  • Use analogWrite() to send variable-intensity signals to pins
  • Understand Pulse Width Modulation (PWM) — the clever trick that makes "analog" output possible on digital pins
  • Create custom functions that accept multiple parameters
  • Mix red, green, and blue light to produce yellow, cyan, magenta, white, and countless other colors
  • Use efficient programming techniques to keep your code clean and organized

By mission's end, you'll have transformed your sterile spacecraft environment into a customizable light show that responds to your every command.

Understanding RGB LEDs: Your Personal Rainbow Generator

Imagine you're an artist, but instead of paint brushes and a palette, you have three magical flashlights — one red, one green, and one blue. By adjusting how bright each flashlight shines, you can create virtually any color imaginable. That's exactly how an RGB LED works!

RGB stands for Red, Green, Blue — the three primary colors of light. Unlike a regular LED that glows just one color, an RGB LED is actually three tiny LEDs packed into a single clear housing. Think of it as a microscopic traffic light where you control each color individually.

Here's where it gets fascinating: your TV screen works the same way! Those millions of pixels are actually tiny red, green, and blue dots. When you see white on your screen, all three colors are glowing at full brightness. When you see black, none are glowing. Every color in between — the warm yellow of a sunset, the deep purple of space, the brilliant cyan of alien oceans — comes from mixing different intensities of these three primaries.

But here's the challenge: we need precise control over brightness. It's not enough to simply turn each color on or off — we need to dim them to specific levels. That's where something called Pulse Width Modulation comes to our rescue. Think of it as the universe's way of cheating — rapidly flickering a light on and off so fast that your eyes can't detect the flicker, but your brain perceives it as dimmed.

With this RGB LED, you're not just adding light to your spacecraft — you're adding the entire visible spectrum of possibilities.

Wiring Your RGB LED

RGB LED Wiring Diagram

Your RGB LED has four legs, and each serves a crucial purpose in this color-mixing operation:

  1. Longest leg (cathode): Connect to ground (GND) on your HERO Board. This is the common connection that completes the circuit for all three colors.
  2. Red leg: Connect to pin 11 on your HERO Board (marked with ~). This pin controls the intensity of red light.
  3. Green leg: Connect to pin 10 on your HERO Board (also marked with ~). This pin controls green intensity.
  4. Blue leg: Connect to pin 9 on your HERO Board (marked with ~). This pin controls blue intensity.
Critical Note

Only pins marked with a tilde (~) support PWM! These are pins 3, 5, 6, 9, 10, and 11. Other pins won't work for controlling LED brightness.

This is lesson 9 of 31 in 30 Days Lost in Space — a professionally produced Arduino course taught by Dr. Greg Lyzenga (NASA JPL scientist, Harvey Mudd professor). Each lesson features cinematic-quality video produced with a 20-30 person professional crew.

All video lessons are free to watch. Get the kit at craftingtable.com — $100 with a 30-day money-back guarantee.