MicroPython 101

A project-based introduction to micro:bit programming using MicroPython with instructions to build 16 hands-on micro:bit projects. Request Quote

  • Grades 6 - 8
  • 14 lessons
    • Web
  • Python
  • Advanced Course
Course includes
  • 14 lessons
  • 86 activities
  • Enhanced Creativity Tools
  • Automatic Assessment
  • Tutorials and Reviews
  • Coding Puzzles
  • DIY Projects
  • Quizzes
  • Teacher Guides
  • Answer Keys
Prerequisites
No previous coding experience required.

MicroPython 101 Lesson Plan

Lesson: Soundboard
Time: 45+ mins

Introduction

Did you know that students can attach fun objects such as a speaker to their micro:bit? In this lesson, students will create a Speech Synthesizer project where they can make voice effects by adjusting the sound of words and phrases! Additionally, students will tap into their inner musician as they create their own songs in today's micro:bit Music Player project. Note: Sound functions (e.g., music.play() and music.pitch()) require using the piezo speaker.

New Code

  • speech.say() : This function makes the micro:bit say something.
  • speech.pronounce() : This function makes the micro:bit use phonemes.
  • music.play() : This function makes the micro:bit play a note.
  • music.pitch() : This function makes the micro:bit play a note at a given frequency.

Vocabulary

  • Octave: A series of notes.
  • Frequency: How high or low a sound is.
  • Phonemes: A distinct sound in the English language (e.g., the t sound in the word Tynker).

Objectives

Students will...

  • Apply coding concepts to solve challenge activities
  • Create a Speech synthesizer and micro:bit Music Maker project using the micro:bit

Materials

  • 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)
  • Piezo speaker

Warm-Up (5 minutes)

  • Ask your students to answer the following questions:
    • What is something you feel proud of accomplishing in the MicroPython course?
    • What's something you want to improve on (related to coding and/or perseverance skills)?

Activities (45 minutes)

Facilitate as students complete all Soundboard modules on their own:
1. micro:bit Soundboard (Document)

  • Students will read a short document that introduces the lesson.
  • Students will learn that they're going to create two projects:
    • Speech Synthesizer: Students will attach the piezo speaker to their micro:bit and program it to show text of whatever they say. They can even create cool voice effects.
    • micro:bit Music Maker: After attaching the piezo speaker to their micro:bit, students can program their micro:bit to play music.

2. Attaching the Speaker (Example)

  • A speaker needs to be attached to the micro:bit in order for it to play sounds.
  • How to attach alligator clips to their micro:bit and speaker:
    • Step 1: To attach the alligator clips to the micro:bit, attach one clip to pin0 and the other clip to the GND pin:

    • Step 2: Attach the other end of the alligator clips to each wire on the speaker:

      Note: The long pin on the speaker needs to be connected to pin0.
  • Try It Out! Say Something!
    • Make sure students test their speaker by running the completed code.
    • Is sound not coming out of the speaker? Make sure your students attached both ends of the alligator clips. Also make sure the long pin on the speaker is connected to pin0 on the micro:bit.
  • Make sure your student's speaker is working before instructing them to move on to the next module.

3. Project 1: Speech Synthesizer (DIY)

  • Students will learn how to program their micro:bit to say phrases.
  • Point out to students that they can make their micro:bit say different phrases based on which button they press or what gestures they make.
  • Coding Challenge, Step 1: Saying Words
    • To solve this challenge, students need to finish the provided code and make their micro:bit say something when the user presses a button or a gesture is performed.
    • Students are introduced to the speech.say() function, which makes the micro:bit say something.
    • Give a hint: Ask students to use button functions. If they need suggestions on what to say, here's a list they can choose from: "What's Shaking?", "Howdy", "Greetings Earthling".
    • Their code might look something like this:

4. Customizing the Sound (DIY)

  • Students will learn that they can adjust the voice sound of a word or phrase using optional parameters (i.e., pitch, speed, mouth, and throat) in the speech.say() function.
  • Point out to students that they can use the speech.pronounce() function to make their micro:bit say individual sounds. They can use this if the micro:bit is not pronouncing a word correctly or as expected.
  • Coding Challenge, Step 2: Customizing the Voice
    • To solve this challenge, students need to finish the provided code and make their micro:bit say something when the user presses a button or a gesture is detected.
    • Make sure students are using the extra parameters (i.e., pitch, speed, mouth, and throat) for speech.say().
    • If students finish early, ask them to try the bonus activities or try experimenting with the speech.pronounce() function.

5. Project 2: Playing Music (DIY)

  • In this module, students will learn how to make their micro:bit play music.
  • Make sure students analyze the code and comments from the "Try This Out! Play a Song!" activity. Do they recognize the tune?
  • Coding Challenge: Write a Song
    • In this challenge, students need to compose their own tune and make it play on their micro:bit using code. What melodies can they create?

6. Review

  • This page reviews the following:
    • The user can use speech.say() and speech.pronounce() to make the micro:bit play sound.
    • The user can create an interactive experience by adding sound to games/projects.

7. 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:

  • Who can remember the speech.say() parameters? (Answer: pitch, speed, mouth, and throat)
  • Was there a word that the micro:bit didn't pronounce correctly? What word was it? How can you fix it? (Answer: Use the speech.pronounce() function.)

U.S. Standards

  • CCSS-Math:MP.1
  • 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

U.K. Standards

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.