- Grades 6 - 8
- 14 lessons
- Advanced Course
- 14 lessons
- 86 activities
- Enhanced Creativity Tools
- Automatic Assessment
- Tutorials and Reviews
- Coding Puzzles
- DIY Projects
- Teacher Guides
- Answer Keys
MicroPython 101 Lesson Plan
Lesson: Treasure Hunt
Time: 45+ mins
Who's ready for a game of hide-and-seek? In this lesson, students will create a Treasure Hunt game that uses at least two different micro:bits! Additionally, they'll learn new functions as they program a Treasure micro:bit and Treasure Hunter micro:bits. The Treasure miro:bit will be hidden and needs to continually send messages to the Treasure Hunter micro:bits to let them know how close they are to it. Meanwhile, the Treasure Hunter micro:bits will be programmed to display a bar, notifying the player how close they are to the Treasure micro:bit.
Note: The make_grid() function is Tynker specific. If students try using this function in Python projects outside the MicroPython 101 course, it will not work.
- radio.receive_full() : This function receives messages, detects signal strength, gives a timestamp, and returns the word "None" if a message isn't detected.
- make_grid() : This function displays an image (e.g., signal bar) on the micro:bit, depending on the signal strength of the message it receives.
- Apply coding concepts to solve challenge activities
- Create a Treasure Hunt game using the micro:bit
- 2 or more micro:bits
- 2 or more battery packs
- USB cable
- Computers, laptops, or Chromebooks (1 per student) with student account access to Tynker.com
Warm-Up (5 minutes)
- Ask a student to explain the general rules of hide-and-seek. (Example: A person hides while other people try to find them.) Next, tell students that they're going to create their own version of hide-and-seek using micro:bits!
- Optional: Pair up students and ask them to brainstorm ideas of how they'd create their own hide-and-seek game using micro:bits. For example, perhaps a micro:bit will make a beeping sound that will get progressively louder as other micro:bits get closer to it.
Activities (45 minutes)
Facilitate as students complete all Treasure Hunt modules on their own:
1. Treasure Hunt (Document)
- Students will read a short document that introduces the lesson.
- Students will learn that they're going to create a Treasure Hunt game using at least two micro:bits. One micro:bit needs to be the designated Treasure micro:bit. The other micro:bits can be Treasure Hunter micro:bits.
- Treasure micro:bit: This micro:bit is hidden and sending a signal to the Treasure Hunter micro:bits, letting them know if they're close.
- Treasure Hunter micro:bits: These micro:bits are out looking for the Treasure micro:bit. The screen on the Treasure Hunter micro:bits will light up if they're close to the Treasure micro:bit. More lights will appear on the screen, depending on how close it is to the Treasure micro:bit.
- How to play: After students finish programming their game, one micro:bit will be hidden in a designated area of the classroom (e.g., reading center, away from the teacher's desk, etc.). Students will need to use other micro:bits to search for the hidden micro:bit. They can determine how close they are to the Treasure micro:bit by looking at the screen of the Treasure Hunter micro:bits. As they get closer, more lights will fill the Treasure Hunter micro:bits's screen.
2. Project 1: The 'Treasure' micro:bit (DIY)
- In this module, students will learn how to program their Treasure micro:bit. They'll also review the following functions:
- radio.on(): This radio function turns on the radio.
- radio.send(): This radio function will broadcast a message to all the other micro:bits.
- Coding Challenge, Broadcasting the Signal
- To solve this challenge, students need to finish the provided code and add an infinite loop so their micro:bit can send a signal to other micro:bits. Additionally, they'll need to add a sleep() function.
- Give a hint: Ask studentsâ€¦
- What should our infinite loop look like? (Answer: while True: ).
- What function should we use to send a message to the other micro:bits? (Answer: radio.send() )
- What message should the treasure micro:bit send? (Example: "Polo").
- How many milliseconds should we delay the program? (Answer: 100 milliseconds).
3. Project 2: The 'Treasure Hunter' micro:bits (DIY)
- In this module, students will learn how to program their Treasure Hunter micro:bit. The module also mentions the following functions:
- radio.receive(): This function receives messages from the Treasure micro:bit and returns the word "None" if a message isn't detected.
- radio.receive_full(): This function receives messages from the Treasure micro:bit, detects signal strength, gives a timestamp, and returns the word "None" if a message isn't detected.
- make_grid(): This function will display an image on the micro:bit depending on the signal strength of the message it receives.
- Coding Challenge, Step 1: Detecting and Visualizing Signals
- To solve this challenge, students need to finish the provided code and program their Treasure Hunter micro:bits to detect signals and display an image to illustrate the signal's strength.
- Give a hint: Ask studentsâ€¦
- What should we name our variable that stores the data? (Example: message_data).
- What should we assign our message_data variable to? (Answer: radio.recieve_full() )
- What function should we use to display a grid from make_grid()? (Answer: display.show() ).
4. Playing the Game (DIY)
- This module instructs students to experiment with their code as they test and debug their game.
- Make sure the students' Treasure micro:bit doesn't display images. Also make sure the students' Treasure Hunter micro:bits displays an image that looks similar to a loading bar.
- Point out to students that more LEDs should appear on the Treasure Hunter micro:bits, depending on how close it is to the Treasure micro:bit.
- If students finish early, ask them to try the bonus activities. Note: Adding a speaker to the micro:bit requires additional material: 1 speaker and 2 alligator clips per micro:bit.
- Optional: Ask students to experiment with their code and create their own rules.
- This module reviews the following:
- The micro:bit's radio feature can be used to create multiplayer games, where the micro:bits interact with one another.
- make_grid() is a pre-built function on the micro:bit that can be used to display an image (e.g., signal bar).
6. Quiz (Multiple-choice)
- Students will be asked 4 quiz questions to review concepts from this lesson.
Extended Activities (10 minutes)
Lead a discussion with your students:
- Who can think of a way to make the Treasure Hunt game more challenging?
- How did you modify your code? Did anyone create their own rules?
- Did anyone need to troubleshoot their micro:bit? Explain.
- CCSS-ELA: 6-8.RST.3, 6-8.RST.4, 6-8.RST.7
- CSTA: 2-AP-11, 2-AP-13, 2-AP-15, 2-AP-17
- CS CA: 6-8.AP.11, 6-8.AP.13, 6-8.AP.15, 6-8.AP.16, 6-8.AP.17
- ISTE: 1.c, 1.d, 4.d, 5.c, 5.d, 6.b
Key Stage 2 (Years 4-6)
- Design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve problems by decomposing them into smaller parts.
- Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs.
- Understand computer networks, including the internet; how they can provide multiple services, such as the World Wide Web, and the opportunities they offer for communication and collaboration.
- Use technology safely, respectfully and responsibly; recognise acceptable/unacceptable behaviour; identify a range of ways to report concerns about content and contact.
Key Stage 3 (Years 7-9)
- Understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical reasoning to compare the utility of alternative algorithms for the same problem.
- Create, re-use, revise and re-purpose digital artefacts for a given audience, with attention to trustworthiness, design and usability.
- Understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online identity and privacy; recognise inappropriate content, contact and conduct and know how to report concerns.