Teacher Resources: Python with Robots MS Mission 7-2
Hot Pursuit Lesson 2: Auto-Calibration
Students write calibration functions so CodeBot can adapt its proximity sensor detection to any environment.
Overview
In this lesson, students build on the Hot Pursuit program by writing auto-calibration functions for the proximity sensors. They learn how to write a function that calibrates the detection sensitivity threshold and another that calibrates the power level, then test their code across different surfaces and record results. Students also explore the concept of global vs. local variables and use the global keyword when assigning values inside a function.
π― Mission Goal: Students can write calibration functions so CodeBot can adapt to its environment.
Learning Targets
- I can write code that calibrates the detection sensitivity threshold.
- I can write a function for the calibration.
- I can write a function that calibrates the power level.
Key Concepts
- Using auto-calibration functions for power and thresh allows CodeBot to adapt to a new environment.
- An accepted programming convention is to group functions together, typically at the beginning of a program.
- Print statements can take multiple arguments - it converts them to strings and prints them back-to-back to the console, with each argument separated by a comma.
Assessment Opportunities
- Quiz after Objective 5
- Mission 7 Lesson 2 Log
- Submit completed program HotPursuit
- Mission 7 Obj. 4-7 Review Kahoot!
Success Criteria
- Use an if statement to detect a button press
- Use if statements to determine the best detection sensitivity threshold
- Define a function to auto-calibrate thresh
- Define a function to auto-calibrate power
- Use the global command when assigning values to global variables inside a function
- Use multiple arguments in a print statement
- Test the program with multiple surfaces and record the results
Digital Resources
Classroom Materials
- βΈCodeBot and USB cable
- βΈ4 AA batteries
- βΈDifferent testing surfaces (colors, textures, etc.)
- βΈOptional: CodeBot Testing Surfaces
Real-World Applications
Many technical devices use auto-calibration to maintain accuracy.
Extensions & Cross-Curricular
π€
Vocabulary
βΎ
π
New Python Code
βΎ
sensed), check only the LEFT sensor. If it detected a reflection, assign its sensitivity value to a variable.
min() finds the lowest value of its arguments. This selects the lowest value of either the current det or the RIGHT sensor's sensitivity value.
π
Standards
βΎ
CSTA Standards - Grades 6-8
- Look through the slides and 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.
- Have at least three colors/surfaces available for each student or programming pair. You can use the Testing Surfaces paper from Unit 3 as an option - any colors or surfaces will work.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- This lesson is all about auto-calibration, which was also introduced in Mission 6. If you skipped auto-calibration (Mission 6 Objective 8), all the information you need is included here. If your students completed Obj. 8, this will be review.
- This lesson can run long if students do a lot of testing, or if calibration is a new topic. Consider running it over two class periods and including a cross-curricular activity or extension as well.
- This lesson goes over global and local variables. If your students did Mission 6 Obj. 8, it will be review. Otherwise, take extra time here to make sure students understand the concept.
- The code used during the lesson is slightly different from CodeTrek. All goals will be met.
- Students will need different surfaces for testing. You can use the Testing Surfaces paper with black/white/gray options, or any color or surface.
- There is a quiz after Objective 5. It doesn't really review the concepts from 4 and 5. You have the option of skipping the quiz, or going over it together as a class.
Lesson Outline
Slide 2 - Students can write in their log first and then share, or discuss first and then write. The warm-up question reviews proximity sensors. Students can share answers or compare with each other.
- Question: How is the proximity sensor similar to the line sensor?
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 - there is a lot of testing in this mission, so it is a good one for pair programming.
ποΈ Optional: Mission 7 Obj. 4-7 Kahoot! Review - covers Objectives 4 through 7.
The post-mission reflection asks students to review what they learned during this lesson. Answers can vary widely depending on each student's experience.
You can use a cross-curricular activity for a post-mission activity.
End by collecting the Mission 7 Lesson 2 Log.