Mission 3: Light the Way
Light the Way
Turn on CodeBot's LEDs using binary and decimal values, then use the sleep() function to animate them.
Overview
In Mission 3, students move from communicating with CodeBot to controlling its onboard LEDs. They import the botcore library, add comments to their code, and turn on a single LED before using binary and decimal values to control CodeBot's user LEDs all at once. By the end, they use the sleep() function from the time library to animate LED patterns in a controlled sequence.
🎯 Mission Goal: Students learn the basics of Python.
Learning Targets
- I can import a library.
- I can use a predefined function from a library.
- I can use comments to explain my code.
- I can turn on a single user LED.
- I can use binary to turn on multiple LEDs.
- I can use decimal values to turn on or off LEDs.
-
I can delay program execution using the
sleep()function from the time library.
Key Concepts
- Adding comments and blank lines in your code makes it easier to read.
-
Built-in functions come from libraries, like
botcoreortime. - The CodeBot has 17 LEDs, and each can be turned on or off using code.
-
Use the prefix
0bin front of a binary pattern to control LEDs. -
Use the
sleep()function to slow down the computer.
Assessment Opportunities
- Quiz after Objective 3
- Submit program code, or give students printed code and have them explain each line (Objectives 3, 4, and 5)
- Short quiz or exit ticket demonstrating the binary code for turning on a specific pattern of user LEDs
- Level-1 Mission 3 Review Kahoot!
Success Criteria
- Create a new file for program code
- Turn on a single user LED
- Control all user LEDs using binary
- Control all user LEDs using decimal
-
Use the
sleep()function to animate the LEDs - Animate CodeBot's LEDs in a controlled sequence
Digital Resources
Classroom Materials
- ▸Computer or Chromebook with internet access
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
0b to indicate binary.
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
Certiport IT Specialist: Python Standards
PCEP: Certified Entry-Level Python Programmer
- It isn't explicitly mentioned, but students should start a new file for this program code. File names should be descriptive - if students are submitting the file, have them include their name in the filename.
- Have the Mission 3 Assignment ready to hand out or post in your LMS, along with the Assignment Answers key for quick grading.
- Pull up the Mission 3 Review Questions and have the Review Kahoot! link ready to launch for a class-wide review.
- Keep the Mission 3 Final Code Solutions on hand as a reference if students get stuck or you want to compare approaches.
-
Preview binary notation (like
0b11111111) so you can explain it clearly if students ask, even though converting decimal and binary isn't a required skill.
- Discuss readability in code, such as using comments and adding blank lines.
- Students don't need to know how to convert decimal and binary numbers, but it's a fun topic - you can spend extra time on binary numbers as an option.
- Give students time to experiment with controlling the LEDs with binary and with decimal.
- The quiz after Objective 3 checks binary LED control specifically, while Objectives 4 and 5 are better assessed by having students submit or explain their code.
- The Mission 3 Review Kahoot! covers all of Mission 3, not just the binary objectives - use it as a cumulative wrap-up.
Lesson Outline
Have students write or discuss their answers before revealing them.
- Question: Where have you seen lights used to show information, like a status light or a warning light on a device you own?
- Question: If you had to control 8 lights using just one number, how do you think that could work?
Students open CodeSpace, start a new file, and work through the Level-1 Mission 3 Assignment.
from botcore import *) and reviewing comments and blank lines for readability - remind students that a comment like # Turn on LEDs 0, 3, 4, 7 never actually runs.leds.user_num(0, True), and a single line sensor LED with leds.ls_num(0, True), before introducing binary control.leds.user(0b11111111) and leds.ls(0b11111). Give the quiz after Objective 3, once students can turn on all the user LEDs (8 bits) and line sensor LEDs (5 bits) using binary.leds.user(0).sleep() from the time library (from time import sleep) and having students chain LED states with sleep(0.2) between them to animate their LEDs in a controlled sequence.If students finish early or need extra support, point them to the Level-1 Mission 3 Assignment Answers or the Final Code Solutions for reference.
Give a short quiz or exit ticket that has students demonstrate the binary code for turning on a specific pattern of user LEDs.
Have students work through the Level-1 Mission 3 Review Questions individually or in pairs to reinforce vocabulary like binary, bit, byte, and library.
Wrap up with the Level-1 Mission 3 Review Kahoot! to review all of Mission 3 before collecting finished programs.