Teacher Resources: Python with Robots MS Mission 9-1

Mission 9-1 Lesson Plan

All Systems Go! Lesson 1

Students use system sensors to monitor battery power and display battery health with a user interface.

⏰ 45-50 min 🎯 Grades 6-8 💻 CodeSpace 🤖 CodeBot 🐍 Python
View Lesson Outline
📋

Overview

In this first lesson of Mission 9, students learn how to access CodeBot's built-in system sensors to read battery voltage and detect whether the 'bot is powered by batteries or USB. They use that data to calculate battery capacity using a table lookup and then using the equation of a line. Students then create a simple user interface (UI) using the power LED to communicate battery health - no screen required.

🎯 Mission Goal: Students will use system sensors to monitor battery power and display battery health with a UI.

🎯

Learning Targets

  • I can use system sensors to read battery voltage and power source.
  • I can print the capacity percentage using a table.
  • I can calculate the capacity percentage using the equation of a line.
  • I can create a user interface to display battery health using the power LED.
💡

Key Concepts

  • CodeBot can measure its own battery voltage and detect whether it is powered by USB or batteries.
  • System sensor data can trigger alerts to avoid problems. Even without a screen, CodeBot's LEDs can display sensor information.
  • A graph of battery discharge over time can be approximated with a straight line, making it easier to calculate capacity percentage.
  • The power LED - just above the power switch - can be turned on and off with code to communicate battery health.

Assessment Opportunities

Success Criteria

  • Read battery voltage using system sensors
  • Indicate battery or USB power using system sensors and the power LED
  • Display capacity percent using a table
  • Calculate and display capacity percent using the equation of a line
  • Use the power LED as a UI to communicate battery health
🧰

Classroom Materials

  • CodeBot
  • USB cable
  • 4 AA batteries per CodeBot (don't need to be fresh - variety of power levels is more interesting!)
🌍

Real-World Applications

This kind of code is already in the devices students use every day. Many electronics monitor battery power to ensure reliability, extend battery life, and prevent unexpected shutdowns.

📱Cell phones and laptops use battery monitoring to show charge level and manage power usage.
🚗Electric vehicles track battery capacity to display range and warn drivers before power runs out.
🤖Industrial robots monitor power systems to avoid mid-task failures in warehouses and factories.
🏥Hospital and emergency services equipment relies on battery health monitoring where power failures could be life-threatening.
🚀

Extensions & Cross-Curricular

ExtensionCreate an additional UI using the user LEDs. Turn on all four LEDs for full power and decrease the number lit as the battery drains. When all user LEDs are off, the battery is nearly dead.
ScienceTeach a lesson on electricity, voltage, and battery power. Compare battery power readings to USB power from the computer.
MathThis lesson uses percentages. Pair it with a lesson on how to calculate a percent.
MathThis lesson uses the equation of a line to calculate percentages. Have students graph line equations or find the equation from data points.
STEMSuppose CodeBot had a display screen. Have students design a UI that shows battery health and other system information they find interesting.
Lang ArtsSupports language arts through reading instructions, guided notes, and reflection writing.
🔤

Vocabulary

System sensors - Sensors that read internal settings, like power and temperature.
Under load - Batteries are being used to power something, like turning on LEDs or running motors.
Float (review) - A decimal number, either positive or negative.
y = mx + b - The equation of a straight line.
User Interface (UI) - A way for a person and a machine to communicate, which includes screens, keyboards, and LEDs.
🐍

New Python Code

system.pwr_volts() Returns a float (decimal number) for the current voltage - either from USB or batteries.
system.pwr_is_usb() Returns an integer: 0 if the power switch is set to batteries, 1 if USB.
leds.user(15) Turn on the first four user LEDs so the battery is under load.
leds.user(0) Turn off all user LEDs.
pct = (v / 2) - 2 Use the equation of a line to calculate the capacity percentage, given the voltage v.
leds.pwr(True) Turn on the power LED indicator.
leds.pwr(False) Turn off the power LED indicator.
📐

Standards

CSTA Standards - Grades 6-8

2-DA-08 2-DA-09 2-AP-10 2-AP-11 2-AP-12 2-AP-13 2-AP-14 2-AP-16 2-AP-17 2-AP-19
📝
Preparing for the Lesson
  • If your students skipped Mission 8 as recommended, make sure you have entered the classroom dashboard and unlocked Mission 8 so students can continue to Mission 9.
  • 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.
  • All CodeBots need four AA batteries. They do not need to be fresh - a variety of power levels can make the activity more interesting.
  • If you have a word wall, or another form of vocabulary presentation, prepare the new terms.

🧑‍🏫
Teacher Notes
  • This lesson follows the instructions in CodeSpace fairly closely. It is chunked into smaller bits of information and occasionally gives extra examples or definitions.
  • The code in this lesson is similar to CodeTrek. It is simplified a little for ease of typing, and some non-required code is left out. All goals will be met.
  • The activities include a lot of testing using the console panel for printing results. The console panel can be resized to show more text - just drag up the gray line above the tab headings.
  • All CodeBots should have batteries in their battery pack for testing. Batteries don't need to be fresh. In fact, having batteries at a variety of power levels can make the activity more interesting.
  • The lesson uses the equation of a line to calculate the percentage. If your students haven't learned this yet, you can just give them the code or teach a short lesson on the concept first.
🗺

Lesson Outline

💡Lesson Tips and Tricks
Teaching tip: You can use a variety of discussion strategies to get the most engagement from your students. For example, you can have students write their answers before asking anyone to share. You can use think-pair-share, have students compare with a neighbor, or randomly select students to answer.
🗣️Warm-up / Hook - Slide 2

Students can write in their log first and then share, or discuss first and then write. The warm-up questions review CodeBot sensors from previous missions.

  • Question: What are some sensors on CodeBot you know how to use?
  • Question: What other information from a CodeBot sensor would you like to have access to?
💻Mission 9 Lesson 1 Activities

The Chrome browser works best, but other browsers also support CodeSpace. Each student will complete a Mission Log. Students could work in pairs, which is advantageous since this lesson requires testing during each objective.

Teaching tip: Mission Introduction - slides 3-4. This mission is divided into three lessons. This lesson completes the first four objectives. Students answer one question in their mission log.
Teaching tip: Objective #1 - slides 5-6. Battery voltage is introduced. Students learn about CodeBot battery power and what it means to test "under load."
Teaching tip: Objective #1 - slides 7-9. Students learn the functions used to read system sensors for battery voltage and power source.
Teaching tip: Objective #1 Activity - slides 11-15. Students use the Console Panel to practice using the battery functions and record testing results in the mission log.
Teaching tip: Objective #2 - slides 16-18. Students look at a chart plotting battery discharge over time. The chart is simplified to a straight line, and a voltage data table is used to convert voltage into capacity percentage.
Teaching tip: Objective #2 - slide 19. The algorithm for the battery tester program is presented.
Teaching tip: Objective #2 Activity - slides 20-25. Students start a new file for the battery tester program, create two functions and a main program. All code is given in the slides. Students record two results in the mission log.
Teaching tip: Objective #3 - slides 26-27. Students learn to use the equation of a line for a more accurate capacity calculation. A short description of y = mx + b is given.
Teaching tip: Objective #3 Activity - slides 28-32. Students modify one function to use the equation of a line. All steps are given. Students run the program several times to test all data cases and record results in the mission log.
Teaching tip: Objective #4 - slides 33-34. The user interface concept is introduced. Students learn to use the power LED to communicate battery health.
Teaching tip: Objective #4 - slides 35-39. The algorithm for the battery health UI is presented. Code is given step-by-step with explanations. Students can refer back to the algorithm during the activity.
Teaching tip: Objective #4 Activity - slides 40-45. Students add a function for the battery health UI. Code is given, then step-by-step testing instructions. Students record results in the mission log, including one test case where they choose their own battery voltage.
Teaching tip: Extension - slide 46. One extension suggestion is given: use the user LEDs as a battery health UI. Many solutions are possible. Sample code is available in the learning portal.

🗝️ Optional: Mission 9 Obj. 1-4 Kahoot! Review. A review Kahoot! is available for all four objectives in this lesson.

🧑‍🧑Post-Mission Reflection

The post-mission reflection asks students to think about how a battery tester can be used in other CodeBot programs. Answers can vary widely - this is a good topic for class discussion.

You can use a cross-curricular activity as a post-mission activity.

End by collecting the Mission 9 Lesson 1 Log.