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
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
- HTML Color Picker - Find color codes visually
- RGB Color Mixer - Understand color mixing
- Color Psychology - Colors and emotions
Sprint Notes: What’s your favorite color? Find its RGB values (Red, Green, Blue numbers 0-255).
Programming Walkthrough
Setup Your Environment
- Navigate to makecode.microbit.org
- Sign in with your school Google account
- Create a new project named
LED Color Control
Add NeoPixel Support
- Add the NeoPixel extension:
- Click the gear icon ⚙️ in the top right
- Choose “Extensions”
- Search for and add “NeoPixel”
Basic Color Control
- 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
- Press
Downloadand transfer to your micro:bit
Individual LED Control
- 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
- 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
- Click the Home button, then create a new project called
Three Colors. - 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
- Click the Home button, then create a new project called
Custom Colors. - 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
- Click the Home button, then create a new project called
Color Story. - 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?