Lesson 1 - Farm Control Board: Light-Controlled Smart Lamp
This lesson introduces the micro:bit's onboard light sensor and how a program can use it. Students explore how light readings change, then watch and learn as the teacher builds a light-controlled smart lamp that switches on automatically in the dark.
I can explain what a sensor is and how the light sensor detects brightness.
I can make the hardware connection correctly.
I can build a program that turns the light strip on when it gets dark.
1. Engage: What Is a Smart Farm Lamp?
Open by describing the farm shed at night—pitch dark, and the farmer has to walk over and flip a switch every time. Ask the class: is there a smarter way? Could a lamp turn on by itself? The technology behind it is a light sensor.
Key Question
How can a lamp know when it is dark and turn on by itself?
Expected answers: a lamp could sense the light; a sensor tells the micro:bit how bright it is; when it is dark, the lamp turns on.

Definition: A sensor is an input device that detects a physical change in the environment—such as light, temperature, or motion—and turns it into a signal a program can read. The micro:bit has an onboard light sensor that measures how bright the surroundings are.
Tell students: the farm needs a light-controlled smart lamp—let's find out how the micro:bit senses light.
2. Explore: How Does the micro:bit "See" the Light?
Set up the hardware connection (shown below):

Where is the light sensor?
As well as working as an output, the LEDs on your micro:bit can also work as an input device light sensor, measuring the amount of light falling on them.
Activity 1
Have students build and install the hardware following the Building Instruction.

Download the teacher-prepared light-reading program. When the micro:bit is powered on, the LED matrix shows the current light level number.

Have students record the light level under each condition in the table, then discuss the results together:
| Action | Light level |
| Cover the light sensor with your hand. | |
| Shine a flashlight at the sensor. | |
| Turn the room lights on. | |
| Turn the room lights off. |
3. Engineer: Build the Light-Controlled Lamp
Open MakeCode and add the required Extensions (demonstrate on screen).
| Click Extensions | |
| Type boson and search | |
![]() | Click the extension and go back to the coding page |
Demonstrate building the code: add the light level block and an if…then…else comparison with a threshold, then add the show color and clear all blocks.

Download the program and check the effect.
Cover the light sensor → The LED light strip should turn on.
Shine a light at the sensor → The LED light strip should turn off.
Teaching tip: choose the threshold from the students' Explore readings, and explain that the threshold is the ‘darkness’ decision line.
4. Experience & Challenge: Customize Your Smart Lamp
Experience: choose your favorite light color
Activity 2
Ask students to add extension and rebuild the code.


Guide students to explore the Light category to change the color and brightness of the LED light strip when it turns on.


Students can choose their favorite color or combine effects to customize their smart lamp.
Challenge: Improve your smart lamp
Have students run the program and describe what they notice.
Key Question
What happens when the light level is almost exactly at the threshold?
Expected answer: when the light level sits right at the threshold, the strip flickers on and off quickly—annoying and wasteful.
Activity 3
• Challenge students to add the pause (ms) block so the lamp waits a moment before changing state.
• Have students drag the pause block after the show color block and the if-else block. What is the difference?
• 

5. See More: How Do Machines "Sense" and Decide?
Key Question
How does a simple sensor help a machine make a smart decision?
Explain that a machine can't think like we do, but it still needs senses—just as we use our eyes and ears, a machine uses sensors to gather information about the world.
How does it work?
Step 1: Sense
The light sensor reads how bright the room is and turns it into a number—just like our eyes notice when a room is dark.
Step 2: Think
The program compares that number with a threshold. If the number is below the threshold, the micro:bit knows: it's dark!
Step 3: Act
The micro:bit switches on the LED light strip. Sense → Think → Act—this is how almost every smart machine works.
AI takes this one step further. A light sensor gives just one number, but an AI camera senses millions of pixels at once. In Lesson 2, our farm camera will use this same Sense → Think → Act loop to detect faces!
Next lesson: Lesson 2










