Lesson 8 Storage Stage: Ventilation System
Challenges: 8-1, 8-2
Students learn how to use button events to adjust a humidity threshold for controlling a ventilation fan.
I can create a variable to store a humidity threshold.
I can use button events to adjust the threshold value.
I can use conditionals to control a fan based on sensor data.
Engage
2 min.
Different crops need different storage conditions! Potatoes need dry storage—humidity below 60%. Pumpkins can handle up to 75% humidity. Onions need it even drier—below 50%.

How can we build a smart ventilation system that lets us set the right humidity level for whatever crop we’re storing?
Background
3 min.
Variable: A variable is a named container that holds a value. Giving it a clear name helps anyone reading the program understand what it represents.

Fan Module: Unlike components we turn on or off (like a pump), the fan can run at different speeds using the analog P0 output PWM block. The value range is 0–1023, where 0 means stopped, and 1023 is full speed.


NOTE: The fan requires a certain minimum PWM value to start spinning. This threshold is approximately 400, so students are advised to set the PWM value above this number.
Build and Connect
10 min.
![]() | Build together following the Building Instruction. |
After groups finish building, prompt them to discuss the questions below:
In a barn, is moisture higher at the bottom or top? Where should the sensor go—and why?
Where is the fan in your model? Why that position?
Have students install the fan and sensor with pins and liftarm blocks, according to the discussion.
NOTE: Make sure the fan blades are not blocked or touched while spinning.
Program
25 min.
Challenge 8-1: Button Fan Speed Control
![]() | Ask students to connect the DHT11 sensor to P0 and the fan module to P1. |
![]() | ![]() Guide students to open a new project in Mind+ and load program8-1. Show students how to create a variable and have them create a variable for the fan speed with a readable name. |
![]() | ![]() Show students how to use the when button pressed to add 100 to or subtract 100 from a number variable. Guide students to pick a step value (e.g., 50, 100, or 500) and type it into the change speed by block. Ask: "How does the step size affect how you control the fan?"Here is a sample code:Have students discuss how this programming concept could be applied, like to show a score that changes over time. |
![]() | ![]() Explain: Values above 1023 generally won't make it "more powerful"—instead, they can cause issues such as truncation, errors, or unpredictable behavior. Always keep PWM values within the valid range supported by the hardware. Guide students to add constrain block to make the speed stay between 0 and 1023. Here is a sample code: |
Challenge 8-2: Adjustable Auto-Ventilation System
![]() | Ask students to load program 8-2. Explain: "In this challenge, we will build a system that automatically controls the fan based on humidity—and lets us adjust the target humidity without editing the code." |
![]() | ![]() Challenge students to set the starting value of the threshold to 60%. Here is a sample code: |
Extra Practice
5 min.
Challenge students to optimize their ventilation system with an intermittent cycle.

The variable doesn’t know the limit that it represents. Try a different to make the threshold stay between 0 and 100.

Next Class: Lesson 9
Current Tutorial: Click Here




















