Mission 6-3: Line Follower - PwR MS
Line Follower Lesson 3: Proportional Control & Calibration
Students will create a line follower program that uses all five sensors for proportional steering control.
Overview
Mission 6-3 covers the final two objectives in the Line Follower mission. Students write a drive() function with parameters for left and right wheel speeds, then build a proportional line-following algorithm using tuples of sensor readings. In Objective 8, students add a calibration routine that reads sensor values to automatically set the detection threshold, and learn about global vs. local variables.
๐ฏ Mission Goal: Students will create a line follower program that uses all five sensors for proportional steering control.
Learning Targets
- I can define a function for driving at variable speeds.
- I can represent a tuple of bools with 1s and 0s.
- I can compare a variable to a tuple.
- I can use tuples to create proportional speed control.
-
I can calibrate the 'bot by setting the
threshandis_reflectivevariables. -
I can use the
globalkeyword to keep variables global.
Key Concepts
- A function with parameters for left and right wheel speeds enables flexible, reusable drive control.
- A tuple of Boolean values (1s and 0s) can represent which sensors detect the line at any moment.
- Comparing sensor readings to a tuple allows for proportional steering - the 'bot adjusts speed based on how far off the line it is.
- Calibration uses real sensor readings to set a threshold value, making the program adapt to different surfaces and lighting.
-
The
globalkeyword allows a function to modify variables defined outside it.
Assessment Opportunities
- Mission 6 Lesson 3 Log (digital)
- Quiz after Objective 8
- Submit completed program LineFollow (obj7 and/or obj8)
- Mission 6 Obj. 7-8 Review Kahoot!
Success Criteria
-
Define the
drive()function with two parameters - Use cases of detection for proportional speed control
- Compare a variable to a tuple
-
Use pre-coded math functions
abs()andround() -
Define the
calibrate()function -
Call the
calibrate()function when a button is pressed
Digital Resources
Classroom Materials
- โธCodeBot
- โธUSB cable
- โธ4 AA batteries
- โธA track for the 'bot to follow - white poster board with a black line made from electrical tape works well
Real-World Applications
Extensions & Cross-Curricular
๐ค
Vocabulary
โพ
๐
New Python Code
โพ
ย ย ย motors.run(LEFT, left)
ย ย ย motors.run(RIGHT, right)Define a function for driving the 'bot that uses parameters for the left and right wheel speeds.
ย ย ย drive(0, 30)Use the tuple in a comparison. Call the drive() function, selecting left and right speeds as the arguments.
ย ย ย calibrate()Call a function when a button is pressed.
๐
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.
- Decide if you want your students to complete objective 8. You can move on to the remix and next unit without it, and your students would have more time to try different tracks and have a competition. Objective 8 does introduce new programming concepts. So look over the entire lesson and decide what you want to do.
- This lesson covers objectives 7 and 8. Look over objective 8 on calibration and decide if you want your students to do it. The program works fine without it. If you do cover obj. 8, it gets into global and local variables and built-in math functions. The quiz is also optional. You should skip it if you don't do objective 8.
- The slides for objective 7 go into more detail about the tuples used, and give additional examples.
- The CodeSpace instructions for objective 8 have a lot of reading. The slides simplify the instructions but still complete the code from CodeTrek.
- The extensions are the same as the previous lesson. Students may think of their own extension for the program.
Lesson Outline
The warm-up questions review the new concepts and code from Lesson 2.
- Question: What code reads the line sensors and turns on/off the LEDs?
- Question: What data type (information) does ls.check() return?
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 6 Obj 7-8 Kahoot! Review. A review Kahoot! is available for these two objectives.
The post-mission reflection asks students to reflect on their programming experience. Both questions are good for small group or whole class discussion.
You can use an extension or cross-curricular activity as post-mission activity.
End by collecting the Mission 6 Lesson 3 Log.