Mission 5-4: Fence Patrol - PwR MS
Fence Patrol Lesson 4: Stay in the Lines
Students write functions to move CodeBot and use line sensor data to keep it inside a boundary.
Overview
In this final lesson of Mission 5, students bring everything together to create a working Fence Patrol program. They write functions to move CodeBot forward and backward, then use line sensor data to call those functions and keep the 'bot inside a boundary. Students test with a rectangular boundary and can explore other shapes as time allows.
🎯 Mission Goal: Students will create a program that reads line sensors and uses that data to move CodeBot within a boundary.
Learning Targets
-
I can define a function that moves the 'bot.
-
I can call a function that moves the 'bot at the appropriate time and place.
-
I can program the 'bot to stay inside a boundary.
Key Concepts
-
Autonomous robots use sensor data to make decisions and take action in their environment.
-
Functions can be written for 'bot movement as well as reading sensors - movement functions do not return a value.
-
Algorithms can be developed as a plan first, then translated into code step by step.
Assessment Opportunities
-
Mission 5 Lesson 4 Log assignment
-
Submit completed program LineSense
-
Mission 5 Review Kahoot!
Success Criteria
- Define and call a function that moves the 'bot forward
- Define and call a function that moves the 'bot backward and then turns
- Program the 'bot to move inside a boundary line
Digital Resources
Classroom Materials
- ▸CodeBot
- ▸USB cable
- ▸4 AA batteries per CodeBot
- ▸White posterboard with black electrical tape boundary (rectangle to start - try other shapes too!)
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
motors.run(LEFT, 45)
motors.run(RIGHT, 45) Define a movement function. Creates a reusable function that moves CodeBot forward.
go_forward() Call a movement function. Calls
go_forward() when the 'bot is not detecting a line.
📐
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. There are a couple of tables to fill out. Prepare the assignment to give through your LMS.
-
Have posterboard with boundaries ready for students to use for testing. Make sure you have charged batteries for the CodeBots.
-
If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
-
The slides replace the instructions in CodeSpace. Code will be similar to CodeTrek but slightly different - all goals will be met.
-
This lesson isn't very long. Depending on testing and debugging time, students can use extra time for extensions or cross-curricular activities.
-
The simplest boundary is a rectangle on posterboard with black electrical tape (both available at the dollar store). After initial testing, try different shapes and even a white line on a dark surface.
-
The Mission 5 Kahoot! reviews all Mission 5 objectives - not just Objective 9.
Lesson Outline
Slide 2 - Students can write in their log first and then share, or discuss first and then write. These questions review movement and turning code. Students can reference Mission 3 NavSquare or Mission 4 Animatronics if they need a refresher.
- Question: What code will move the 'bot forward?
- Question: What code will move the 'bot backward?
- Question: What code will turn the 'bot?
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.
🗝️ Optional: Mission 5 Kahoot! Review. The review Kahoot! covers all Mission 5 objectives.
The post-mission reflection asks students to think about functions and how they are useful in programming. This is a good topic for class discussion.
You can use an extension or cross-curricular activity as a post-mission activity.
End by collecting the Mission 5 Lesson 4 Log.