Lesson 5 Growing Stage: Farm LED Light Project
Challenges: 5-1, 5-2
Students will design and code pest trap lamps and farm guide lights using an LED strip.
I can control the LED strip with buttons.
I can show different colors in different ranges.
I can program moving light effects.
Engage
2 min.
Discuss the questions below:
What can lights be used for in the field?
They can guide people, attract and trap pests, and even signal information.

When building these smart farm lighting devices, except for the UNIHIKER K10, what else hardware do we need?
Background
3 min.
The LED strip (WS2812) is a programmable light strip containing multiple individual LEDs. Each LED can be set to a specific color individually.

NOTE: The strip light has two sockets. Please make sure to connect the correct side (the arrow start) to the UNIHIKER K10’s pin socket, and the other socket is for extending the strip light.
Initializing block: This block tells the UNIHIKER K10 to prepare the LED strip connected to pin P0. The number 7 tells it we have 7 LEDs to control on this strip.

Show color block: This block sets a range of LEDs to a specific color.

NOTE: We number the LEDs on the strip starting from 0. For a strip of 7 LEDs, the index numbers are 0, 1, 2, 3, 4, 5, 6.
Build and Connect
10 min.
![]() | Build together by the Building instruction. |
Program
25 min.
Challenge 5-1: Basic Control with Buttons
![]() | ![]() Ask students to connect the LED strip to the UNIHIKER K10. Here is a sample: |
![]() | Guide students to rebuild the program and discuss:What do you notice?Does every LED light up? |
![]() | ![]() Ask students to change the numbers in the show color block from 0, 4 to 0, 6. Encourage them to explain what these numbers represent. Here is a sample: |
![]() | ![]() Explain that each LED on the strip needs a unique number as its index, like an address, so we can control them individually. Ask students to number the LEDs on the strip from 0 to 6. Here is the answer: |
![]() | ![]() Challenge students to add the show color blocks and modify the range and the color of the block. Here is a sample:Remind students to choose the color that the pest likes. |
NOTE: Install the LED strip on the plate to make the next project—the guide light.

Challenge 5-2: Creating a Moving Guide Light
![]() | Ask students to load the starter project program5-2 and predict. Upload and discuss:Was your prediction correct?Which block makes the lights move?To move the lights, the program needs the rotate pixel block. The number means how many LEDs it moves each time. |
![]() | Prompt students to find a speed that they like best by modifying the number in the wait block. |
Extra Practice
5 min.
Guide lights might be too bright and harsh. Explore other blocks in the LED strip (WS2812) library. How can we change the brightness of the LEDs to create a softer scene?

Investigate the following block and the meaning of its parameters. What new lighting effect can you create?

Next Class: Lesson 6
Current Tutorial: Click Here





















