Haunted Code Chronicles - Mission 2: The Living Room
The Living Room
Students will learn how to read the proximity sensors and use them to detect when the television is on or off.
Overview
Mission 2 moves the story into the living room, where a television flickers on and off. Students munch popcorn, curve the 'bot across the room, and then meet CodeBot's proximity sensors. They print sensor readings to the console, wrap those readings in an infinite while loop, and use an if statement to react, first by lighting LEDs and then by starting and stopping the motors to cross the room while the TV is off.
π― Mission Goal: Students will learn how to read the proximity sensors and use them to detect when the television is on or off.
Learning Targets
- I can move the 'bot in a curve.
- I can identify the proximity sensors.
- I can read the proximity sensors and print the reading on the console.
- I can use an infinite while loop to constantly read the proximity sensors.
- I can use an if statement to turn on and off LEDs.
- I can use the proximity sensor readings to start and stop CodeBot.
Key Concepts
- The REPL is also known as the console. It can be used to print data. Students will print to the console during this mission.
-
A while loop defines a block of code that is repeated while a condition is True. A while loop definition ends with a colon (
:) and the block of code to be repeated must be indented. - An if statement has at least one branch. It uses a condition that is True or False. If the condition is True, the first branch is executed. If the condition is False, the else branch is executed.
-
An if statement definition ends with a colon (
:) and the blocks of code in the branches are indented. -
The proximity sensors return a tuple of Boolean values, which are either True or False. The tuple looks like this:
(True, True)or(False, False)
Assessment Opportunities
- Complete the Mission 2 Activity Guide.
- Complete and turn in program PopcornMunch after Objective 2.
- Complete and turn in program LivingroomEscape after Objective 7.
- Complete the Quiz after Objective 5.
- Record the score for the mission, found in the Progress and Contests icon under Select Class.
- Write a paragraph about their coding experience and what they learned.
Success Criteria
- Munch several pieces of popcorn by touching them with CodeBot
- Identify the proximity sensors
- Read the proximity sensors and print the reading to REPL (the console)
- Use an infinite while loop to read the proximity sensors
- Use an if statement and the proximity sensor reading to turn on/off a line sensor LED
- Guide CodeBot through the door, moving only when the television is off
Digital Resources
Classroom Materials
- βΈLaptop/computer with Chrome browser
π€
Vocabulary
βΎ
Optional Computing Terms
π
New Python Code
βΎ
Optional Python Code
def munch(left, right, tm):Define a function. Function names follow the same rules as variables. The block of code inside a function must be indented.
munch(55, 50, 4)Call a function (no parameters). Call a function with parameters.
π
Standards
βΎ
CSTA Standards - Grades 3-5
CSTA Standards - Grades 6-8
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
- Go through the Mission in advance, if you can. Try at least the first couple of objectives.
- Be familiar with opening and closing the console.
- The mission has two activity guides. They use the same questions, but the alternative guide (alt) gives added support with the questions. Use the one that best fits the needs of your students.
- New programming concepts have very specific syntax. Students need to be really careful with how they type in the code.
- An infinite while loop will be used starting with Objective #5. The code will not end until the STOP button is pressed.
- The console icon in the toolbar opens the console. Once the console is open, the same icon changes and is used to close it again.
-
Whenever CodeTrek has
# TODO:students should not type the comment, but they should type the actual code to accomplish the task. Sometimes CodeTrek will give additional help, and sometimes students are expected to know the code. They can look back in the Objective Panel to remember what to do.
Lesson Outline
The warm-up has two questions. The first one is a review of the code from Mission 1.
Before students answer the second question, go over the Mission 2 introduction. Emphasize the second paragraph about the television. You can even go to Objective 1 and close the Objective Panel to see the television and the face that appears on it. Then have them guess how CodeBot can detect if the face is showing. If they don't have previous coding or robotics experience, they probably won't know. Any guess is good, and at the end of the mission they can compare their guess with the actual sensor.
The reflection questions can be written, shared as a class discussion, or handled through a think-pair-share activity. This is a good time to review their earlier predictions and what was learned during the mission.