AP CSP CodeX - Mission 10: Reaction Time
Mission 10: Reaction Time
Students use the CodeX internal clock to build a reaction time tester, and write functions to keep their code short and readable.
Overview
During this mission, students use the CodeX internal clock to measure how fast they can react. They display a countdown, wait for a button press, and use time.ticks_ms() and time.ticks_diff() to calculate the elapsed time. Along the way they write functions to follow the DRY idea: never write the same code twice. After Objective 7, students create at least one more function from the main program to make it easier to read.
🎯 Mission Goal: Students will use CodeX's internal clock to create a device to measure reaction time.
Learning Targets
- I can write a function to make code more efficient and readable.
- I can utilize multiple variables in a new program and describe their purposes.
- I can use functions from the time library to calculate reaction time.
Key Concepts
- Computers are driven by internal clocks.
-
Use the
time.ticks_ms()function to record the current computer time. - Debounce the button press to detect only the most recent button press.
- The DRY concept. Never write the same code twice!
Assessment Opportunities
- Mission 10 Assignment
- Reaction_Time program
- Mission 10 Kahoot! Review
Success Criteria
- Display a countdown
- Clear the screen
- Clear the pixels
- Create a function for the wait_button
- Use the start time and end time to calculate the elapsed time
- Display the reaction time
Digital Resources
Classroom Materials
- ▸CodeX
- ▸USB-C cable
- ▸Computer
Real-World Applications
- Outdoor and porch lighting
- Coffee makers
- Home security
- Irrigation systems
- Livestock feeding
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
AP CSP Framework
- The assignment is best completed digitally. Prepare the assignment to give through your LMS.
- If you have a word wall, or another form of vocabulary presentation, prepare the new terms.
- Decide on a warm-up topic that your students may need to review, such as functions or common programming errors.
- Encourage the students to do as much code on their own as they can, and use CodeTrek to check their work, or as a hint when needed.
- The assignment adds an extra step to complete after Objective 7, before turning in the program.
- If you have time at the end of the lesson, use the Mission 10 Kahoot! Review.
- Refer to the lesson plans in the Python with CodeX Mission Pack Curriculum for additional challenges, cross-curricular suggestions, and additional information.
Lesson Outline
This outline gives the narration for one way to present the lesson.
There is no specific warm-up for this lesson. As a teacher, decide on a topic that may need review with your students before starting the mission. You may want to review functions, or you can go over common programming errors. Keep it to a quick review and then get right to the mission.
Randomly group students into pairs for pair programming (or they can work individually).
Students log in to one computer. Two computers can be used if they want to have the assignment open on one computer and CodeSpace on the other computer.
Students go to make.firialabs.com and should be at the beginning of Mission 10.
randrange. There are some questions students need to answer on the assignment document. They should read the instructions carefully.import time instead of from time import sleep. This means whenever they use sleep in their code, they need to use time.sleep(). If they are getting errors, be aware of this.✅ The assignment is complete and ready to turn in.
Optional. Use a formative assessment for the wrap-up.
Formative assessment:
- Daily reflection journal
- Mission 10 Kahoot! Review (in class or individual)
- Exit ticket or group review on functions, local variables, or loop conditions