Teacher Resources: Python with Robots MS Mission 9-2
All Systems Go! Lesson 2
Students use system sensors to monitor temperature and build a UI that displays LED alerts when readings fall outside an acceptable range.
Overview
In this lesson, students read system temperature data from the CodeBot using built-in sensors and use it to build a thermostat-style user interface. They learn to collect temperature samples, calculate a moving average, and define constants for a baseline and deadband. The 'bot's LEDs serve as visual alerts when the temperature is too high or too low.
π― Mission Goal: Students will use system sensors to monitor system temperature and display unacceptable temperatures with a LED-based UI.
Learning Targets
- I can use system sensors to read system temperature in either Celsius or Fahrenheit.
- I can find the average of several temperatures.
- I can create a UI that uses LEDs to show an alert if the average temperature is too high or too low.
Key Concepts
- The 'bot can measure its own system temperature.
- Just like system power data, temperature data from system sensors can be used to trigger alerts. The CodeBot's LEDs can show when temperatures are out of range.
- The system sensors can measure temperature in either Celsius or Fahrenheit.
- The CodeBot CB2 (older model) has a more exposed CPU than the CB3, which makes it easier to test temperature changes in real time. Specific CB2 instructions appear at the end of the slide deck.
Assessment Opportunities
- Mission 9 Lesson 2 Mission Log
- Submit completed program TemperatureCheck
- Mission 9 Obj. 5-7 Review Kahoot!
Success Criteria
- Read system temperature using system sensors
- Define an empty list for temperature readings
- Get a sum of all temperatures in the list
- Return the average of temperatures in a list
- Define constants for baseline and deadband
- Turn on/off LEDs as an alert when the temperature is too high or too low
Digital Resources
Classroom Materials
- βΈCodeBot and USB cable
- βΈOptional: ice pack and/or heat pack for testing (CB2 model only)
Real-World Applications
Many electronic devices use a temperature-control system - or thermostat - to avoid overheating or overcooling. Students are already using this kind of code every day:
Extensions & Cross-Curricular
check_baseline() function to turn off LEDs when the condition is no longer met.
π€
Vocabulary
βΎ
π
New Python Code
βΎ
π
Standards
βΎ
CSTA Standards - Grades 6-8
- Look through the slides. Decide what materials you want to use for presenting the lesson. The slides can be projected on a large screen.
- Be familiar with the mission log assignment and the questions students will answer. Prepare the assignment to give through your LMS.
- Students may want to use a calculator for the Obj. 5 mission log assignment.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- If you have the older CB2 model, have hot and cold options available that can heat/cool the CodeBot CPU. Disposable water bottles work well and won't damage the CodeBot (see slides 40-41).
- This lesson follows the instructions in CodeSpace fairly closely. It is chunked into smaller bits of information and simplified for clarity.
- The code in this lesson is similar to CodeTrek - simplified a little for ease of typing and organized in a way similar to former missions. All goals will be met.
- Three extensions are given for the lesson. The lesson may not take an entire class period - the first extension is recommended and includes detailed instructions.
- The older CodeBot model (CB2) has a more accessible CPU than the CB3. At the end of the lesson, additional instructions are given for testing with the CB2. If you have CB3 models, skip those slides.
Lesson Outline
Slide 2 - Students can write in their log first and then share, or discuss first and then write. The warm-up question previews the lesson.
- Question: What do you know about temperature?
The Chrome browser works best, but other browsers also support CodeSpace. Each student will complete a Mission Log. Students can work in pairs or individually.
sleep_ms() function is introduced and compared to sleep().check_baseline() function has a bug where LEDs don't turn off, then work through the fix. Sample code for this extension is available in the learning portal.The post-mission reflection asks students to think about how a temperature-controlled system could be used in other CodeBot programs. Answers can vary widely.
A cross-curricular activity makes a good post-mission option.
End by collecting the Mission 9 Lesson 2 Log.