Mission 5-1: Fence Patrol Lesson 1 | Python with Robots MS
Fence Patrol Lesson 1: Reading Line Sensors
Students will read and display data from CodeBot’s line sensors using the debugger, console panel, and Boolean variable assignment.
Overview
Mission 5-1 introduces students to CodeBot’s line sensors. Students learn how analog sensors work, how to read real-time sensor values using ls.read(), and how to view those values using both the CodeSpace debugger and the console panel’s print() statement. Students also explore how different surface colors and reflectivity affect sensor readings.
🎯 Mission Goal: Students will read and display data from CodeBot’s line sensors.
Learning Targets
-
I can use
ls.read()to get real-time line sensor values. - I can display values in the console panel’s debug window to get real-time sensor values.
- I can print values to the console panel while running a program to display real-time values.
- I can assign a Boolean value to a variable by using an if statement as part of the assignment statement.
Key Concepts
- Analog sensors are non-contact sensors used in many industrial and commercial applications.
-
The console panel can be used to print real-time data using the
print()statement. - A dark line on a light background will have a larger value, toward the high end of the range. A light line on a dark background will have a smaller value, toward the low end of the range.
- A variable can be assigned a Boolean value by using an if statement as part of the assignment statement.
Assessment Opportunities
- Mission 5 Lesson 1 Log (digital) - includes a chart for recording reflective values of different surfaces
- Submit completed program LineSense
- Mission 5 Obj. 1-2 Review Kahoot!
Success Criteria
- Read values from a single line sensor
- Use the debugger to see values in real time
- Print a value to the console panel
- Assign a Boolean value to a variable using an if statement
Digital Resources
Classroom Materials
- ▸Various surfaces for testing reflectivity (student desk, folder, carpet, construction paper, etc.)
- ▸CodeBot
- ▸USB cable
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 6-8
- 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.
- Print the Test Surfaces paper for each student or programming pair. Also have additional surfaces available for testing - things like a folder or notebook, a piece of carpet, colored construction paper, shiny wrapping paper, etc.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- The slides should replace the instructions in CodeSpace. Code will be similar to CodeTrek, but a little different. All goals will be met.
- Objective 1 requires students to use the debugger. It has been awhile since students used the debugger. You may want to do this part together, or model it first.
- In Objective 2, there is a slide on APIs. This isn’t necessary for the lesson and can be skipped if you want to.
- Extra slides are included that go into a little detail about analog and digital. You can use them or skip over them. This lesson is on the shorter side, so you have time to discuss the topic.
Lesson Outline
Slide 2 - Students can write in their log first and then share, or discuss first and then write in their log.
- Question: What are some things you would like CodeBot to detect?
Students can share their answers, or compare with each other.
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. Part of the mission log is to fill out a chart, so working in pairs is a good suggestion for this lesson.
print() statement. Students do not need to use the debugger, but they will open the console panel. If the "Debug" window is still active, they need to click on "Console" to make that the active window. The prints will be displayed there. The concept of REPL is not addressed here - it is introduced in Mission 6.sleep() to slow down the display. It is slightly different from CodeTrek.🗽 Optional: Mission 5 Obj 1-2 Kahoot! Review - a review Kahoot! is available for these two objectives.
The post-mission reflection asks students to review the values of a line sensor reading, and think about future uses of line sensors.
You can use an extension or cross-curricular activity as a post-mission activity.
End by collecting the Mission 5 Lesson 1 Log.