Lesson 7 - Health Care: Sleep Status Monitor

Lesson 7 Health Care: Sleep Status Monitor

 

image3.png Challenges: 7-1, 7-2

Students will program with a pressure sensor and an LED strip to monitor sleeping.

image5.png I can read the pressure sensor and use it to detect if someone is in bed.

image5.png I can use AND to combine two conditions into a compound conditional.

image5.png I can make a difference between or and and block.

Engage

image7.png 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.

image9.png

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

image7.png 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.

image10.png

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

image11.png

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).

image12.png

Build and Connect

image7.png 15 min.

image13.pngBuild 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

image7.png 25 min.

image14.png Challenge 7-1: Bed Occupancy Detector

image16.pngGroups should open the Coding page-Mind+, connect their hardware.
image17.pngAsk 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."
image18.pngimage19.png
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.

image20.png

image14.png Challenge 7-2: Soothing Sleep Light

image21.pngimage22.png
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:
image23.pngChallenge 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

image7.png 5 min.

Ask students to explore the display category to create a more comfortable sleeping environment.

image24.png

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

image25.png

 

 

Next Class: Lesson 7

Current Tutorial: Click Here

icon Lesson 7.zip 3.2MB Download(0)
License
All Rights
Reserved
licensBg
0