Lesson 3 - Home Lighting: Staircase Light Programming

Lesson 3 Home Lighting: Staircase Light Programming

 

image3.png Challenges: 3-1, 3-2

Students program UNIHIKER K10 to show different light modes.

image5.png I can turn on and off LEDs in different ranges.

image5.png I can make a rainbow strip light and change its brightness.

image5.png I understand the difference between on start and forever and use them correctly.

Engage

image7.png 2 min.

Start a brief class discussion. Ask students to think about their own homes. What happens when they turn on a stair light? Is it too bright? Not bright enough? Does it light up all steps? This real-world problem sets the stage for today's programming challenge.

image9.png

How can we provide safe and comfortable lighting when going up and down the stairs at night?

Background

image7.png 3 min.

The LED strip is made of 7 individual LEDs (Light Emitting Diodes) that we can control with code.

We can tell each LED what color to be and how bright to shine, all from our program.

image10.png

NOTE: the LED strip’s block is in its library, which need to be import from Extension’s page.

image11.png

The show color block is how we tell the program to use the LED strip. It can show different colors in different range of the LED strip.

image12.png

Build and Connect

image7.png 10 min.

image13.pngBuild together by the building instruction.

Students should set up the stair LED strip and connect it to the UNIHIKER K10 using the correct pins.

Program

image14.png 25 min.

image15.png Challenge 3-1: Exploring Basic LED Control

image17.pngAsk students to make hardware connections.
Have students prepared for programming.
image18.pngGuide students to rebuild the program to turn on the entire LEDs on the LED strip.
image19.pngimage20.png
Encourage students to control different numbers of LEDs.
Can you light just the first three? Or every other one?There's no single right answer here. The goal is for students to discover how to target specific LEDs in the strip.
Here is a sample:
image21.pngimage22.png
Challenge students to use the show gradient color block to create a rainbow effect.
Prompt them to modify the last two parameters.
Try setting from 0 to 120, what color do you get? What about 240?Introduce the color wheel to reveal the relationship between colors and parameters.
The parameters correspond to Hue (H) values: 0/360 = red, 120 = green, 240 = blue.
image23.pngimage24.png
Encourage students find a level that would be perfect for a night light - not too dim, not too glaring.
Here’s what the completed program3-1 should look like.

image15.png Challenge 3-2: Create a Flowing Light

image25.pngimage26.png
Students have to add more blocks to the program so that LEDs rotate forward. Here’s what the completed program should look like.
image27.pngIncreasing the time in the wait blocks will make the lights rotate forward more slowly. Prompt students to find a speed that they like best.
image28.pngDrag the rotate sequence into the forever block. The loop will then run continuously.
You can find the completed program3-2 in the attachment.

Extra Practice

image14.png 5 min.

Go back to your rainbow effect code.

Drag the pick random block from the operators category into the last parameter of show gradient color block. What happens?

image29.png

 

 

Next Class: Lesson 4

Current Tutorial: Click Here

icon lesson 3.zip 2.56MB Download(0)
License
All Rights
Reserved
licensBg
0