Teacher Resources: Python with Robots MS Mission 7-1
Hot Pursuit Lesson 1: Proximity Sensors
Students use CodeBot's infrared proximity sensors to detect objects and experiment with power and threshold settings.
Overview
In this first lesson of Mission 7, students explore CodeBot's infrared (IR) proximity sensor system. They start with basic object detection using the default function, then add power and threshold parameters to adapt detection for different surfaces. Finally, students use a scanning function to find the best threshold settings for white and black surfaces - collecting and recording real data along the way.
π― Mission Goal: Students use proximity sensors to detect an object.
Learning Targets
- I can use proximity sensors to detect objects.
- I can indicate a detected object using the proximity sensor LEDs.
- I can experiment with light and dark surfaces to find the best power and detection threshold settings for each surface.
- I can use a pre-defined function to scan multiple settings to find the best detection threshold for a given power setting.
Key Concepts
- CodeBot uses the Infrared Proximity Sensor system to detect objects in its path.
- A detection threshold of 0-100% controls how much light is needed for a True detection. Decreasing the thresh value helps the 'bot work well even on a white surface.
-
An emitter power level from 1 to 8 controls the brightness of CodeBot's IR "flashlight." The
prox.detect(power, thresh)andprox.range(num_scans, power)functions let students adapt to different environments.
Assessment Opportunities
- Mission 7 Lesson 1 Log assignment
- Submit completed program HotPursuit
- Mission 7 Obj. 1-3 Review Kahoot!
Success Criteria
-
Use the basic function
prox.detect()to detect objects in front of the sensors. -
Use the reading from
prox.detect()to turn on/off the proximity sensor LEDs. - Measure the detection distance for a white surface using different power and thresh values.
- Measure the detection distance for a black surface using different power and thresh values.
-
Use the function
prox.range()to find the best threshold for detecting IR light on a white surface. -
Use the function
prox.range()to find the best threshold for detecting IR light on a black surface.
Digital Resources
Classroom Materials
- βΈCodeBot and USB cable
- βΈ4 AA batteries
- βΈWhite paper
- βΈBlack paper
- βΈRuler (or print the White paper with ruler doc)
Real-World Applications
Extensions & Cross-Curricular
while True loop to cycle through the power range and print the results to the console. This is a fast way to test all the powers for many different surfaces, and can be an alternative to using the console panel exclusively in Objective 3.
π€
Vocabulary
βΎ
π
New Python Code
βΎ
(left, right).
power sets IR brightness (1-8). thresh sets detection sensitivity (0%-100%). leds.prox(p) turns on the LED below each sensor if an object is detected - for example, if p = (True, False), the left LED turns on and the right stays off.
num_samples (up to 10), power. Returns the best threshold for the given power setting.
π
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.
- Have white and black surfaces available for each student or programming pair.
- Have a ruler available for each student or programming pair, or print the "White paper with ruler" PDF.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- The code for Objectives 1 and 2 is the same as CodeTrek. You can use the slides or CodeTrek.
- The code for Objective 3 is different from CodeTrek. You can type the code directly in the console panel without adding to the program. However, the last goal in the objective will not be met until you add a line of code - this is detailed in the slides.
- Students will need a white surface and a black or very dark surface. Regular printer paper and black construction paper work well. For Obj. 2, students need to measure distance - you can put a ruler next to the surfaces, or use the PDF in the teacher resources, which has a metric ruler. Just put the black construction paper over the white paper for the second table.
- This lesson can run long if students do a lot of testing. You can condense it and have students do less testing, stretch it slightly into the next day, or use the extension for Objective 3 instead of typing all the code in the console panel.
Lesson Outline
Slide 2 - Students can write in their log first and then share, or discuss first and then write. These questions review line sensors and have students make a prediction for this mission.
- Question: How does a line sensor work?
- Question: How do you think CodeBot can "see" objects?
The Chrome browser works best, but other browsers also support CodeSpace. Each student will complete a Mission Log. Students could work in pairs through the lesson, or they can work individually. There is a lot of testing in this mission, so it is a good one for pair programming.
prox.detect() so the programmer has more control over detection. Both parameters are explained.π Optional: Mission 7 Obj. 1-3 Kahoot! Review covers all three objectives.
The post-mission reflection asks students to review the objectives in this lesson.
You can use a cross-curricular activity as a post-mission activity.
End by collecting the Mission 7 Lesson 1 Log.