Lesson 7 Health Care: Sleep Status Monitor
Challenges: 7-1, 7-2
Students will program with a pressure sensor and an LED strip to monitor sleeping.
I can read the pressure sensor and use it to detect if someone is in bed.
I can use AND to combine two conditions into a compound conditional.
I can make a difference between or and and block.
Engage
5 min.
Babies sometimes wake up many times at night. It's hard for parents to know if the baby is sleeping peacefully or about to wake up.

How can we build a smart bedside monitor that checks if someone is in bed and creates a soothing sleep environment with a LED light strip?
Background
10 min.
Pressure Sensor
This sensor changes its resistance when pressure is applied. The harder you press, the higher the analog reading. We can place it under a bed mattress to detect if someone is lying in bed.

NOTE: Do not pull up on the pressure-sensitive film, as this may break the connection and damage the module.

The read analog P0 block reads the pressure value from the sensor connected to pin P0. The value ranges from 0 (no pressure) to 4095 (maximum pressure).

Build and Connect
15 min.
![]() | Build together by following the Building Instruction. |
After groups finish building, prompt them to discuss the questions below:
Where would you place the pressure sensor to best detect if someone is in bed?
What should the LED strip do when the bed is empty vs when someone is sleeping?
Encourage students to install the pressure sensor on the bed using pins.
NOTE: Here is a suggested way to install the pressure sensor.
Program
25 min.
Challenge 7-1: Bed Occupancy Detector
![]() | Groups should open the Coding page-Mind+, connect their hardware. |
![]() | Ask students to read the pressure sensor value when pressing lightly vs firmly. Guide them to find a good threshold number that distinguishes "someone in bed" from "empty bed." |
![]() | ![]() Encourage students to modify the if-then-else block: If pressure > threshold -> show "Someone in bed" and turn the LED strip on. Else -> show "Bed empty" and turn the LED strip off. Here is a sample code: |
Introduce the key vocabulary compound conditional and AND.
In Challenge 7-1, we check only one condition: is it dark? But a smart night light needs to check TWO things: is it dark AND is someone getting out of bed? We can combine conditions using the AND block to make a compound conditional.

Challenge 7-2: Soothing Sleep Light
![]() | ![]() Guide students to combine both conditions using the AND block:if light < 100 AND pressure > 1000 -> LED strip ON (warm white), screen shows "Sleep at night". Else if pressure > 1000 AND light ≥ 100 -> LED strip OFF, screen shows "Nap". Else -> LED strip OFF, screen shows "Bed Empty". Here is a sample code: |
![]() | Challenge students to swap AND for OR and observe the difference. Ask: "What happens when you use OR? Why is AND better for this project?" This reinforces the difference between AND and OR. |
Conclusion:
Compound conditional: combining two or more conditions in one if statement using AND, OR, or NOT. AND means both must be true. OR means at least one must be true. Choosing the right logical operator is key to making a program behave correctly.
Extra Practice
5 min.
Ask students to explore the display category to create a more comfortable sleeping environment.

Prompt students to use the NOT block to learn more about conditions.

Next Class: Lesson 7
Current Tutorial: Click Here

















