Lift-Off with CodeX - Mission 10: Exploring the Surface!
Exploring the Surface
The crew has landed on Mars and the rover has to explore. Students build a sonar warning system on a breadboard so the rover can spot an object, measure how far away it is, and react before it gets too close.
Overview
A new journey begins. After landing on Mars, the crew has a new job ahead of them, exploring the surface. But if the CodeX, which is standing in for the rover, is damaged, the peripherals students have been using so far may not work.
This project moves off the peripheral ports and onto a breadboard. Students wire an ultrasonic sensor and two LEDs with resistors, use sonar to detect an object, convert the echo time into a distance in centimeters, and build a warning system that keeps the rover away from anything harmful.
🎯 Mission Goal: Students write code to simulate a warning system for a rover.
Learning Targets
- I can connect a breadboard to the CodeX.
- I can connect external peripherals to the breadboard.
- I can use sonar to detect an object.
- I can convert sensor time data to a distance in centimeters.
- I can create a warning system for the rover.
Key Concepts
- The types of components that can connect to the CodeX are greatly expanded with a breadboard.
- A sonar can detect an object and how far away it is.
- A well-known formula for distance is used to calculate how far away an object is.
- The CodeX timer can be used in several types of applications.
Assessment Opportunities
- Check for Understanding in CodeSpace (2)
- Mission 10 Assignment
- Write instructions, or draw a diagram, for connecting a sensor on a breadboard
- Explain how sonar works
- Exit ticket - write pseudocode for setting up an alarm system using an if/elif/else statement
- Submit and/or check the ExploreSurface program
- Journal entry on their learning experience
Success Criteria
- Connect the breadboard to the CodeX.
- Use jumper wires for the sensor's power, ground, and input/output.
- Interpret data from the sonar sensor by calculating the distance to an object.
- Create two simple circuits using an LED and resistor.
- Create a warning system for the rover based on the distance to a harmful object.
- Add a function to "power down" the rover.
Digital Resources
Classroom Materials
- ▸Laptop/computer with the Chrome browser
- ▸CodeX and connecting cable
- ▸Metric ruler to measure centimeters
- ▸Small objects to place in front of the CodeX
- ▸Breadboard and jumper wires
- ▸2 LEDs (amber and red) and 2 resistors
- ▸Ultrasonic sensor
Real-World Applications
Extensions & Cross-Curricular
🔤
Vocabulary
▾
🐍
New Python Code
▾
📐
Standards
▾
CSTA Standards - Grades 6-8
CSTA Standards - Grades 9-10
CSTA Standards - Grades 11-12
- Students need a computer or laptop with the Chrome web browser.
- Make sure students can successfully log in to make.firialabs.com.
- Build the breadboard circuit yourself once ahead of time. Wiring the sensor and both LEDs before class makes it much easier to troubleshoot student rigs.
- Gather the small objects students will use as obstacles and have metric rulers ready for measuring.
- The project requires a breadboard connected to the CodeX for power. Additional components are added from there. First the ultrasonic sensor, to detect an object and return the timing data. Then students use that data to calculate distance and drive the LEDs as a warning system so the rover can avoid harmful objects.
- This is the first mission where students wire components themselves instead of plugging into a peripheral port. Expect wiring mistakes, and treat them as part of the lesson. Have students check power, ground, and signal in that order.
- Good discussion and research questions come easily here, warning systems, sonar detection, and autonomous vehicles. This technology shows up in a huge number of real-world applications.
- Extensions and cross-curricular projects are included to enhance the concepts in the mission. Use them to extend students' programming experience.
- A Final Project follows Mission 10.
Lesson Outline
Students access prior knowledge by answering the pre-mission questions in the assignment doc.
- Ask: "The rover is driving across Mars with no one steering it. How does it know something is in the way?"
- Ask: "Name a warning system you run into in daily life. What information does it use to decide when to warn you?"
Front-load the hardware before any code. This mission moves off the peripheral ports and onto a breadboard for the first time.
- Show the breadboard and explain terminal strips, the columns of holes that are wired together underneath.
- Connect the breadboard to the CodeX for power, and point out where power and ground land.
- Introduce jumper wires and walk through the sensor's three connections, power, ground, and input/output.
- Explain how sonar works. The trigger sends out a sound wave, the echo pin listens for it to come back, and the sensor reports the round-trip time in microseconds.
-
Introduce
import pulseioandpulseio.PulseIn(exp.GPIO0)for setting up the echo pin.
Students work through the mission objectives in CodeSpace, taking notes and answering questions in their assignment doc as they go. There are two Checks for Understanding along the way.
- Connect the breadboard to the CodeX, then wire the ultrasonic sensor with jumper wires for power, ground, and input/output.
-
Set up the trigger and echo, then read the raw timing value with
echo[0]. Useecho.clear()before each new reading. - Convert the echo time into a distance in centimeters using D = R x T, remembering the signal travels out and back.
-
Add a timeout so the program does not hang when nothing is detected, using
return -1to break the loop. - Build two simple LED circuits on the breadboard, amber and red, each with a resistor.
- Write the warning logic with if/elif/else, then add a "power down" function to finish the ExploreSurface program.
Bring the class back together to connect the wiring, the math, and the warning logic.
- Ask: "How does sonar measure distance when all it gets back is a time?"
- Ask: "Why did we divide the round-trip time in half?"
- Ask: "What should the rover do at each warning level, and who decides where those cutoffs go?"
Students answer the reflection question in the assignment doc, add a journal entry about their learning experience, and submit the ExploreSurface program.
Use the Mission 10 Review Questions or the Mission 10 Review Kahoot! through whichever method you prefer, class discussion, Kahoot!, or an LMS quiz.