- 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: Maze Madness
Time: 45+ mins
In this a-maze-ing lesson, students will learn how to program the micro:bit pins to interact with real life objects as they create a maze game! How to play: After creating their own maze, students will need to use a wand to navigate through it. If the wand touches the sides of the maze, the micro:bit will detect it, and the game will end. Note: In order for the game to work, the 3V pin on the micro:bit needs to be connected to the maze, whereas the wand needs to be connected to pin0. Each student will need aluminum foil and cardboard to create their maze. To create a wand, students can use a pen, stick, colored pencil, or whatever else they prefer.
- pin0.read_digital() : This function allows the micro:bit to detect if a current is flowing through pins. If the pins are connected, the function will return 0. If the pins aren't connected, the function will return 1.
- pin0.is_touched() : This function allows the micro:bit to detect if the user is touching a specified pin.
- Use the micro:bit to run coding examples
- Apply coding concepts to solve challenge activities
- Create a maze game using the micro:bit
- micro:bit device (recommended 1 per student)
- USB cable
- Computers, laptops, or Chromebooks (1 per student) with student account access to Tynker.com
- Alligator clips (2 per micro:bit)
- Maze material: cardboard, aluminum foil, pen, pen cap
Warm-Up (5 minutes)
- Tell students that they're going to learn how to create their own maze game in today's lesson! Next, show them an example of what their maze can look like:
- Give students a piece of paper and ask them to sketch a maze design.
Activities (45 minutes)
Facilitate as students complete all Maze Madness modules on their own:
1. Maze Madness (Document)
- Students will read a short document that introduces the lesson.
- Students will learn that they're going to create a maze game that uses the micro:bit pins to detect if the player touches the sides of the maze.
- How it works: After students finish designing their maze and coding their game, they will need to use an alligator clip to connect the wand (e.g., pen cap) to pin0 on their micro:bit. Next, they'll need to use another alligator clip and connect the foil on the maze to the 3V pin.
2. Detecting Pin Connections (DIY)
- Emphasize to students that their micro:bit can detect electrical signals coming into the pins.
- Students are introduced to the pin0.read_digital() function, which shows if a current is flowing through pins. If the pins are connected, the function will return 0. Otherwise, the function will return 1.
- Explain to students that the provided image is illustrating that the micro:bit is lit because there is a connection (current is flowing) between pin0 and the 3V pin:
- Coding Challenge: Testing Pin Connection
- To solve this challenge, students need to finish the provided code and make their micro:bit light up, notifying the user that pin0 is connected to 3v.
- Give a hint: Tell students they'll need to use the == operator.
3. Creating the Maze (DIY)
- This page is broken up into three different sections:
- Making the Maze: Students can either design a maze that's similar to the provided example or they use the maze design they created during today's "Warm-Up" activity. Make sure they read the instructions carefully. Next, students need to attach one end of the alligator clip to the aluminum foil on the maze. The other end of the alligator clip needs to attach to the micro:bit's 3V pin.
- Making the Wand: Students are instructed to wrap one end of the wand (e.g., pen cap) with aluminum foil. Make sure one end of the alligator clip is clipped onto the aluminum on the wand. The other end of the alligator clip needs to be clipped to the micro:bit's pin0.
- Try It Out! Run the Maze: This step requires students to use the code they wrote earlier and test if their maze works. When the wand touches the foil, the micro:bit should flash.
4. Testing the Game (DIY)
- This module instructs students to experiment with their code as they test and debug their maze game.
- Make sure an image appears on the micro:bit when the pen or stick touches the aluminum on the maze.
- If students finish early, ask them to...
- Help a friend finish creating their game
- Try playing a neighbor's maze game
- Design a new maze that's more challenging
- Complete the bonus activities
- This page reviews the following:
- The pins on the micro:bit are sometimes called GPIO, which is short for general purpose input/output.
- Students can use alligator clips with the pins on the micro:bit
6. Quiz (Multiple-choice)
- Students will be asked 5 quiz questions to review concepts from this lesson.
Extended Activities (10 minutes)
Lead a discussion with your students:
- What did you find more challenging: designing/creating your maze or programming your maze game?
- What function detects if a current is flowing through pins on the micro:bit? (Answer: pin0.read_digital() )
- 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.