Haunted Code Chronicles - Mission 5: The Library
The Library
Students will use an equation with modulo to turn on lamps in a pattern and use an accelerometer to drive up a ramp.
Overview
Mission 5 brings two new concepts into the library. First, students learn the different kinds of division Python offers, including integer division and modulo, and use an equation to light the library lamps in a repeating sequence. Then they meet CodeBot's accelerometer, unpack the three values it returns, and use those readings to keep the 'bot driving straight up a fallen bookshelf.
π― Mission Goal: Students will use an equation with modulo to turn on lamps in a pattern and use an accelerometer to drive up a ramp.
Learning Targets
- I can label the parts of a division problem.
- I can use modulo in an equation.
-
I can use the
int()function in an equation. - I can read the accelerometer.
- I can use an accelerometer reading to keep CodeBot moving up when its surroundings are turning.
Key Concepts
- Programmers can use different types of division. In addition to float (or decimal), there is also integer division and modulo.
- Modulo returns the remainder only of a division problem.
- CodeBot has an accelerometer that tracks its position through gravitational acceleration in three dimensions. This allows the 'bot to detect motion and also use the values for navigation.
- The accelerometer returns three values: x, y and z. The values are returned in a tuple, which can be unpacked for easy access.
Assessment Opportunities
- Complete the Mission 5 Activity Guide.
- Complete and turn in program BookBox after Objective 1.
- Complete and turn in program Lamplighter after Objective 4.
- Complete and turn in program BookshelfRamp after Objective 6.
- Record the score for the mission, found in the class dashboard.
- Write a paragraph about their coding experience and what they learned.
Success Criteria
- Move the 'bot to knock a box off a book
- Turn on a line sensor LED to turn on a lamp
- Use a loop to light all lamps in a sequence
- Use an equation with modulo to light all lamps in a sequence
- Drive CodeBot straight up a fallen shelf
- Drive CodeBot straight up a fallen shelf using an accelerometer reading
Digital Resources
Classroom Materials
- βΈLaptop/computer with Chrome browser
π€
Vocabulary
βΎ
π
New Python Code
βΎ
motors.run(RIGHT, 30)Steer left
motors.run(RIGHT, 20)Steer right
π
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.
- During the lesson, students create three different programs. Prepare all three programs, so you can be aware of potential problems and help students with solutions.
- There are two new concepts in this mission: modulo (Objectives 1-4) and using the accelerometer (Objectives 5-6).
- If you would like to give your students more practice with types of division, you can use the Types of Division unplugged lesson.
Lesson Outline
This mission uses modulo. The warm-up questions prepare students for this type of division. You can model long division for your students and do a whole class review on the terms. For more instruction, use the unplugged Types of Division lesson.
# TODO:, but to type the actual code instead.from time import statement adds time. The light variable is deleted. Make sure students are paying careful attention. The Hints go over modulo and integer division and give examples. The third Hint has the actual code for the equation. Students need to be very careful with parenthesis when typing the equation. Even one misplaced parenthesis can cause the program to fail.# TODO:, but to type the actual code instead.while True: loop to their code. All the code inside the loop must be indented! The second hint gives a lot of help with the if statement. It shows an if / else statement. If students use an if / elif / else statement they will get a higher score. A function can be used, but it doesn't affect the score.The reflection questions can be written, shared as a class discussion, or handled through a think-pair-share activity. This is an opportunity to think about applications of the new concepts, outside of the challenge.