Day 1: Color Control

Learn how to control LED strip colors programmatically. Today you’ll explore the relationship between code and visual output through colorful NeoPixel LEDs.

Table of Contents

  1. Learning Objectives
  2. Color Theory Exploration
    1. Resources
  3. Programming Walkthrough
    1. Setup Your Environment
    2. Add NeoPixel Support
    3. Basic Color Control
    4. Individual LED Control
  4. Exercises
    1. Three Colors
    2. Custom Colors
    3. Color Story

Learning Objectives

By the end of this lesson, you will be able to:

  • Control individual LED colors in a strip
  • Understand RGB color values and mixing
  • Create simple color patterns
  • Use the MakeCode environment to program microcontrollers
Learning Focus Skill Development
Concepts How to control LED strip colors
Application Creating patterns with multiple colors
Tools MakeCode programming environment

Color Theory Exploration

Before programming, explore how colors work in digital systems:

Resources

Sprint Notes: What’s your favorite color? Find its RGB values (Red, Green, Blue numbers 0-255).


Programming Walkthrough

Setup Your Environment

  1. Navigate to makecode.microbit.org
  2. Sign in with your school Google account
  3. Create a new project named LED Color Control

Add NeoPixel Support

  1. Add the NeoPixel extension:
    • Click the gear icon ⚙️ in the top right
    • Choose “Extensions”
    • Search for and add “NeoPixel”

Basic Color Control

  1. Build this starter code in blocks:
on start
└─ set strip to NeoPixel at pin P0 with 10 leds as RGB
└─ set strip brightness 50
└─ show color Red
└─ show strip
  1. Press Download and transfer to your micro:bit

Individual LED Control

  1. Now control individual LEDs. Update your code:
on start
└─ set strip to NeoPixel at pin P0 with 10 leds as RGB
└─ set strip brightness 50
└─ show color Red
└─ set pixel color at 4 to White
└─ show strip
  1. Download and test again

Documentation: Take a picture of your LED strip showing red with one white LED. Save this for your assessment portfolio.


Exercises

Three Colors

Approaching

  1. Click the Home button, then create a new project called Three Colors.
  2. Make your strip show these colors in order:
    • First 2 LEDs: Red
    • Next 3 LEDs: Green
    • Rest of the LEDs: Blue

Optional: try it with the range block.

Write in your sprint notes…

What block did you use to set different sections of LEDs?



Custom Colors

Proficient

  1. Click the Home button, then create a new project called Custom Colors.
  2. Create an alternating pattern using 2 different custom RGB colors (not the built-in color options).

Hint: in ... more, use the red...green...blue... block.

Write in your sprint notes…

What RGB values did you use?



Color Story

Distinguished

  1. Click the Home button, then create a new project called Color Story.
  2. Create a light pattern that tells a simple story or represents an emotion using at least 4 different colors. Examples:
    • Sunset colors fading from yellow to orange to red to purple
    • Holiday theme with red and green alternating
    • Ocean depths going from light to dark blue

Hint: Maybe use this color mixer?

Write in your sprint notes…

What story/emotion did you choose?