Mission 6-1: Line Follower Lesson 1 | Python with Robots MS

Mission 6-1: Line Follower Lesson 1 | Python with Robots MS
Mission 6-1 Lesson Plan

Line Follower Lesson 1: Detecting Lines with Sensors

Students will detect lines using line sensors and display the data on LEDs using a Boolean list.

⏰ 40-45 min 🎯 Grades 6-8 💻 CodeSpace 🤖 CodeBot 🐍 Python
View Lesson Outline
📋

Overview

Mission 6-1 introduces students to Python lists and how they can be used to store and work with collections of sensor data. Students learn how to define a list, access items by index, update list items using line sensor readings, and use REPL to test code interactively. The mission builds directly on Mission 5, using familiar sensor code as a foundation for learning list concepts.

🎯 Mission Goal: Students will detect lines using line sensors and display the data on LEDs using a Boolean list.

🎯

Learning Targets

  • I can define a list and access its items.
  • I can update items in a list using sensor data.
  • I can use REPL to gather real-time data from sensors.
  • I can use a list of Boolean values to turn on/off LEDs.
💡

Key Concepts

  • There is no "hidden magic" going on here! The 'bot responds to programmed inputs and outputs.
  • The line follower 'bot will need to continuously check for the presence of a line beneath all five sensors.
  • The debug window in the console panel can display current values of variables. The console window can be used to test code.

Assessment Opportunities

☑️

Success Criteria

  • Define a list with five Boolean values
  • Define a function that returns a list of bools
  • Update items in the list using sensor data
  • Observe list values in the debug window
  • Test a line of code in REPL (console window)
  • Use a list of bools to turn on/off LEDs
📁

Digital Resources

  • Mission 6 Lesson 1 Slides
  • Mission 6 Lesson 1 Log
  • Mission 6 Lesson 1 Answer Key
  • Mission 6 Obj. 1-3 Review Kahoot!
  • CheckLines_obj3 sample code
  • CodeBot Test Surfaces
🤖

Classroom Materials

  • CodeBot
  • USB cable
  • White paper with a black line made from electrical tape
🌍

Real-World Applications

📊Lists are used in the real world and in programming in many ways. They are often used to manage collections of data, such as items in an inventory system or locations in a game simulation. Lists are just one type of data abstraction.
🚀

Extensions & Cross-Curricular

ExtensionAdd code or pressing BTN-1 to stop the program.
ExtensionAdd a sound when a line is detected, and a different sound (or no speaker) when no line is detected.
ScienceTest the sensitivity of CodeBot's sensors by trying different threshold values and tracking the data.
MathCreate a chart from the data collected during the science experiment above.
Lang ArtsSupports language arts through reading instructions, guided notes, and reflection writing.
🔤

Vocabulary

List - A sequence of items you can access with an index.
Index - The position of an item in the list; used to access a specific item.
REPL - Read Evaluate Print Loop - the command line that lets you type Python statements directly and observe what happens.
🐍

New Python Code

detected = [False, False, False, False, False]Define a list. Items are separated by commas and enclosed in brackets.
num_items = len(a_list)Get the length of a list (number of items).
first_item = a_list[0]Access a single item in a list using its index. The first item is at index 0.
if is_detected: detected[n] = TrueUpdate the item at index n in a list.
leds.ls([True, True, False, False, False])Use a list of bools to turn on/off LEDs.
vals = check_lines(2000) leds.ls(vals)Return a list of Boolean values from a function, then use the list to turn on/off LEDs.
📐

Standards

CSTA Standards - Grades 6-8

2-DA-08 2-DA-09 2-AP-10 2-AP-11 2-AP-12 2-AP-13 2-AP-14 2-AP-16 2-AP-17 2-AP-19
📝
Preparing for the Lesson
  • 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 the Test Surfaces paper available for each student or programming pair. They will also want a small black paper to act as a line - a piece of black electrical tape on a piece of white paper works well.
  • If you have a word wall, or another form of vocabulary presentation, prepare the new terms.

🧑‍🏫
Teacher Notes
  • The examples given in the slides are more in line with variables and examples from Mission 5.
  • The code used in the slides is similar to CodeTrek, but a little different. It uses code and variable names from the program in Mission 5. All goals will be met.
  • Slides go into a lot more detail about lists, giving more examples and practice.
  • It is not recommended to use the quiz after Obj. 2. Since the examples and program code are slightly different, the quiz questions aren't applicable if you are using the slides instead of the instructions.
🗺️

Lesson Outline

💡Lesson Tips and Tricks
Teaching tip: You can use a variety of discussion strategies to get the most engagement from your students. For example, you can have students write their answers before asking anyone for an answer. You can use one of many think-pair-share methods. You can have students write their answer and share with someone, and then have other students share answers they heard from their peers. You can randomly select students to answer.
🗣️Warm-up / Hook

Slide 2 - Students can write in their log first and then share, or discuss first and then write in their log. The warm-up questions review code from Mission 5.

  • Question: How do you read a line sensor?
  • Question: What surface colors have the highest readings?
  • Question: What code assigns a Boolean value from a reading?

Students can share their answers, or compare with each other.

💻Mission 6 Lesson 1 Activities

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.

Teaching tip: Mission Introduction - slides 3-7. This mission is divided up into three lessons. The first lesson focuses only on the first part of the first goal. Students answer one question in their mission log.
Teaching tip: Objective #1 - slides 8-12. These slides introduce the topic for the objective and the need for a list.
Teaching tip: Objective #1 - slides 13-16. These slides give additional information about lists, and have students practice identifying parts of a list in their mission log.
Teaching tip: Objective #1 - slides 17-18. These slides transition to how the program will use a list. Students open their program from Mission 5 and review the two functions. They will write similar code for this lesson.
Teaching tip: Objective #1 Activity - slides 19-24. Students start a new file and copy the code from the slide. The code is slightly different than CodeTrek, keeping the same variables and code from Mission 5. They must use the debugger to meet the last goal. Make sure the console panel is open and students have clicked on the "Debug" window. Then they have to click on "Locals" to see the detected, is_detected, n, and thresh variables.
Teaching tip: Objective #2 - slides 25-26. This objective introduces REPL and using the console window in the console panel. REPL was discussed in Mission 5 but not used until now, so the information from Mission 5 is presented here.
Teaching tip: Objective #2 Activity - slides 27-29. This entire activity is completed in REPL. Students type code directly into the Console Window and observe the results. Students should use the Test Surfaces paper and a small black paper (or tape) for testing.
Teaching tip: Quiz - slide 30. It is recommended to skip the quiz. You can unlock the mission so students skip it and go on to Objective 3, quickly go over the answers, or just give students the answers. If following the instructions in CodeSpace the questions make sense, but they don't follow the slides.
Teaching tip: Objective #3 - slides 31-34. This objective shows how to use the list of bools to turn on/off LEDs. A couple examples are given. You might want to take time on slide 33 to show how the list of bools is the reverse order of the binary number: leds.ls(0b00110) goes from LED 4 down to LED 0, while leds.ls([False, True, True, False, False]) goes from LED 0 up to LED 4. Students can practice conversions with a chart in the mission log. The last row on the chart is for students to make up their own LED example.
Teaching tip: Objective #3 Activity - slides 35-36. This is a very small change to the program code. Students should use the Test Surfaces paper and a small black paper (or tape) for testing. At the end of this objective, students should have a working program to turn in.
Teaching tip: Extension. Two extensions are offered for students who have extra time or want to try their programming skills. They are completely optional.

🗝 Optional: Mission 6 Obj 1-3 Kahoot! Review - a review Kahoot! is available for these three objectives.

🤘Post-Mission Reflection

The post-mission reflection asks students to review code for working with lists, and to think about general uses for lists in a program.

You can use an extension or cross-curricular activity as a post-mission activity.

End by collecting the Mission 6 Lesson 1 Log.