Lesson 5 Smart Window: Light-based Control System
Challenge 5-1, 5-2
Students will program with light sensor and servo.
I can explain if then else conditionals in a program.
I can use if then else conditions.
I can use a flowchart to plan and organize my ideas.
Engage
2 min.
In summer, the sunlight is very strong, direct sunlight exposure makes the home hot.

How can we make a smart roof windows to create a more
comfortable space that opens and closes based on the light brightness?
Background
3 min.
How does the house sense the light brightness? The light sensor reports the intensity of ambient light from 0–4095, where 0 is full darkness and 4000–4095 is direct sunlight. The ambient light value in the average classroom is anywhere from 3000 to 4000.

The program uses an if then else block to choose which servo angle to run in different lighting conditions. The conditions are established with a hexagonal comparison block.

Build and Connect
15 min.
![]() | Build together by the Building instruction. |
After groups finish building, prompt them to discuss the questions below:
If the closed window is at 0°, what degree is appropriate to open the window clockwise?
On a hot noon with direct sunlight, what should the smart windows do?
Program
20 min.
Challenge 5-1: Observe the Program & Describe in Natural Language
![]() | Ask students to predict what they think will happen. |
![]() | Encourage students describe the process in the if/then frame. |
![]() | Groups should open Coding page-Mind+, connect their hardware, upload the project (program5-1) to try it. |
NOTE: If 0° does not fully close the roof window, remove the servo, adjust the window’s angle, then reset the servo.


![]() | After groups finish coding, ask students to describe how the if then else conditional in the starter code works by using the sentence frame below:Ifthen. Example student answer:“If the ambient light is greater than(>) 2000, the windows open. If the light is not greater than 2000, the windows close.” |
Introduce the key vocabulary flowchart.
A flowchart uses shapes and arrows to clearly show how a program works step by step.
· Start: Shows how the program begins.
· Arrows: Show the order of steps.
· Branches: Show different conditions (e.g., lightness strong / weak).
· Outcomes: Show what happens when conditions are met or
not.
Challenge 5-2: Complete the Flowchart & Adjust Threshold
![]() | Fill the flowchart to explain how the smart window works. |
![]() | Students will need to adjust the comparison value so that the windows close properly under your classroom’s light conditions. When the light sensor detects bright sunlight, the windows will close. Setting the value to 4000 works for most classroom light levels. |
NOTE: If the classroom light is too strong, move the light sensor to a darker area inside the house for a lower reading.

Extra Practice
5 min.
Ask students to change greater than (>) to less than (<) in the comparison block so that it reads ambient light < 4000. Then challenge students to change the blocks in the program to make smart window system behave the same.
Next Class: Lesson 5
Current Tutorial: Click Here
















