micro:bit L2 - Grow Light Control

Lesson 2 - Grow Light Control

Students learn how to use a variable to control the brightness of a grow light strip.

image1.png I can explain what a variable is and how it stores data.

image1.png I can use the micro:bit buttons to increase and decrease the variable value.

image1.png I can explain why the light period matters for plant growth.


 

1. Engage: What if Indoor Plants Don’t Get Enough Light?

Plants on a windowsill or in a classroom corner often look weak—pale leaves, slow growth, stems stretching toward the window.

image3.png

Key Question

What happens to indoor plants when they don’t get enough light?

Hydroponic plants are usually grown indoors, so they lack sufficient light. We need an “artificial sun” that gives plants the light they need, whenever they need it.

Let’s build a smart grow light with our micro:bit and let the students be the “light keepers” for their plants!


 

2. Explore: How Does the Light Strip Work?

Show students the full-spectrum grow light strip and connect it to the building block expansion board.

image4.png

Then insert the micro:bit into the expansion board

image5.png

Open the MakeCode editor and connect the micro:bit.

Build the program and download.

image6.png

image7.png

Click here to open program2-1

After downloading, the grow light strip lights up.

Key Question

Is the light bright or dim? What color does it look?

Tell students: The brightness of the LED strip is controlled by the analog write block. You can output an analog signal to the corresponding pin. For the LED strip, the higher the signal value, the brighter the LEDs.

image8.png

Teacher NOTE:

The analog write block does not generate a true analog voltage. Instead, it relies on PWM (Pulse Width Modulation) to rapidly toggle a digital pin on and off. Adjusting the proportion of time the LED remains illuminated in each cycle alters the average current, which in turn controls brightness.


 

3. Engineer: Control Brightness with a Variable

This section is demonstrated by the teacher. Students watch and discuss; they do not program yet. The goal is to introduce the concept of a variable.

Show students how to create a variable called brightness to remember a number.

image9.png

image10.png

Build the program and download.

image11.png

Click here to open program2-2

 

Now change the variable value to 255, 768, 1023 and download each time so students can watch the strip get dimmer and brighter.

Explain that a variable is a named place in the program that stores data. By storing the brightness number in a variable, we can change one value and the light follows—no need to rewrite the whole program.


 

4. Experience & Challenge: Adjust Brightness with Buttons

Key Question

How can we change the variable without rewriting the program?

Experience: Use Buttons to Change the Variable

Activity 1

• Rebuild the code in MakeCode.

image12.png

• Download to the micro:bit and test:

• ✅ Press button A several times → the grow light gets dimmer

• ✅ Press button B several times → the grow light gets brighter

Our light now responds to buttons—but we cannot see the level at a glance.

Key Question

How can we show the current brightness level on the micro:bit screen?

Challenge: Show the Brightness Level on the Screen

Activity 2

• Encourage students to design their own display—a number, a bar chart, or a custom icon—as long as it shows the level changing with the buttons. Encourage students to explain their design to the class.

Teacher Note:

A simple way is to use a plot bar graph of brightness up to 1023.

image13.png

Click here to open program2-3
 

5. Elaborate: Why Do Plants Need Light—and Darkness?

image14.jpeg

Key Question

Why are there so many lights on at night on this dragon fruit farm? Can you guess?

Reveal the answer: dragon fruit is a long-day plant. It needs a long period of light to flower and set fruit, so farmers add light at night to extend its “daytime.”

Just like animals, plants need a rhythm of light and dark. The length of day and night—called the photoperiod—tells plants when to grow, flower, or rest.

Activity 3

• Ask students to research the light needs of three different plants.

Connect back to our project: a smart hydroponic system can use a timer or a light sensor to give each plant the right amount of light—exactly what we are building toward.

 

Next Lesson: Lesson 3

Cuurent Tutorial

icon lesson 2.zip 2.1MB Download(0)
License
All Rights
Reserved
licensBg
0