Teacher Resources - Python with Robots MS - Mission 2-2

Mission 2-1: Introducing CodeBot | Python with Robots MS
Mission 2-2 Lesson Plan

Introducing CodeBot Lesson 2: Your First Program

Students connect CodeBot to the computer, write their first Python program, and use code to light up the LEDs.

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

Overview

In Mission 2 Lesson 2, students physically connect the CodeBot to their computer using a USB cable and run their first Python program. They create a new file in CodeSpace, import the botcore leds library, and use Python code to turn user and line sensor LEDs on and off. Along the way, students learn foundational coding practices like writing comments, using correct capitalization and syntax, and understanding Boolean values.

🎯 Mission Goal: Students will connect the CodeBot to the computer, create their first Python file, and write code to control the LEDs.

🎯

Learning Targets

  • I can safely connect and disconnect the CodeBot using the USB cable.
  • I can create a new file.
  • I can write code using the conventions of comments and syntax.
💡

Key Concepts

  • Python requires all objects - variables, peripherals, etc. - to be spelled exactly the same; capitalization matters!
  • Adding comments and blank lines in your code makes it easier to read.
  • Python programmers can import a library, or module, to access pre-defined functions.

Assessment Opportunities

☑️

Success Criteria

  • Create a new file
  • Import the botcore library
  • Use code to turn on an LED
  • Use descriptive comments
🧰

Classroom Materials

  • CodeBot
  • USB cable
🔤

Vocabulary

Comment - Notes in a program code that don't get executed (more information in Mission 3).
Import - Provides access to a module, or library, of pre-defined Python objects and functions to use in your code.
Boolean - A data type that has two possible values: True or False.
🐍

New Python Code

from botcore import ledsImport from botcore only the leds object and its functions
leds.user_num(0, True)Turn on one user LED (arguments are LED number 0-7, True=on, False=off)
leds.user_num(7, False)Turn off user LED #7
leds.ls_num(0, True)Turn on a line sensor LED (arguments are LED number 0-4, True/False)
🌍

Real-World Applications

💡Many electrical devices have single-color LEDs. Discuss devices that have them and what they are used for.
🚀

Extensions & Cross-Curricular

ExtensionMake a poster or chart of Python commands.
ExtensionTurn on the line sensor LEDs.
ExtensionCombine user and line sensor LEDs to create a pattern, like turning on the even LEDs and leaving the odd LEDs off.
Lang ArtsStudents write about technology today and its impact.
ScienceHave a lesson on LEDs and light.
📝
Preparing for the Lesson

Students will need a CodeBot and USB cable for this lesson. Students can work with a partner (pair programming) or individually 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 they will answer. Prepare the assignment to give through your LMS (or print it for each student).
  • If you have a word wall, or another form of vocabulary presentation, prepare the new terms.

🧑‍🏫
Teacher Notes
  • This is a good time to discuss common programming practices, such as descriptive variable names, adding comments and blank lines, use of capital letters, etc.
  • You may want to create a poster of Python commands to refer back to during the Mission.
🗺️

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 - slides 2-3

Students can write in their log first and then share, or discuss first and then write in their log. The two warm-up questions are review from Lesson 1. You can modify them if you want to do a different warm-up.

  • Question: What are some peripherals on CodeBot?
  • Question: What is the difference between inputs and outputs?
💻Mission 2 Lesson 2 Activities

Students need the CodeBot, a USB cable, and a computer or laptop with access to the Internet. The Chrome browser works best.

Each student will complete a Mission Log. Students can work in pairs or individually.

Teaching tip: Objective #6 -- slides 4-6 Students will click on the USB connector in the simulator to complete the goal. They should also connect the CodeBot physically. Students will answer a question in their mission log assignment.
Teaching tip: Objective #7 -- slides 7-8 Usually the CodeBot only needs to go through this connection process one time. But it is useful to see the message and know what to do if it happens periodically. The instructions in CodeSpace use CodeX in the images, but it is the same for CodeBot.

The button MUST be clicked first to connect. You can't just click OK.
The target should be USB CodeBot, not CodeX. The instructions in the slides and workbook will show CodeBot.
Teaching tip: Objective #8 -- slides 9-10 The name of the new file must match the name in the goal. No spaces should be used in filenames.
Teaching tip: Objective #9 -- slides 11-14 Students cannot copy and paste code from CodeTrek. They must type their own code, but they can use the code in CodeTrek to know what to type. Sometimes it gives the code, and sometimes it gives a # TODO: (to do). This is a good time to emphasize the purpose of # TODO:. Students should not type the # TODO, but substitute the actual code where the # TODO: is.
Teaching tip: Objective #10 -- slides 15-18 First students read about capitalization and punctuation. They answer two questions in the mission log. Then they learn more about the two lines of code: import and Boolean values. They answer two more questions in the mission log. Finally, students type in the two lines of code and turn on a single user LED.
🗝️ Teaching tip: Objective #10 Challenges -- slides 19-21 Three challenges are given to extend Objective 10 and give students a chance to be creative. The extensions are listed in the "Extensions / Cross Curricular" section above. The challenges can be omitted, depending on your students and the time frame. If you have time, I recommend having your students do the challenges.
🧑‍🤝‍🧑Post-Mission Reflection

The post-mission reflection asks students to reflect on their experience so far with programming. You can change the question if there is something else you want to emphasize with your students. This can be a very good question to share-out with the class.

  • What is something you learned about programming today?

You can use an extension or cross-curricular activity as post-mission activity. If students do the challenges (or extensions) you can have students do a gallery walk and appreciate the work and creativity of each other.

Optional: Start a poster for Python code.

End by collecting the Mission 2 Lesson 2 Log.

You can review with a Mission 2 Obj 6-10 Kahoot!