Skip to main content

1.2

Major VersionM

by Pete Prodoehl

Introduction

Connect four Pushbuttons to a Bit Board and control a Piezo with code.

We'll explore how we can make sounds using a piezo speaker with four buttons.

Video Overview

  1. We'll use Maker Tape to connect the four Buttons and the Piezo to the Bit Board on a LEGO baseplate. Connect Buttons to Pin 1, Pin 2, Pin 3, and Pin 4. Each will also connect to Ground (GND).
    • We'll use Maker Tape to connect the four Buttons and the Piezo to the Bit Board on a LEGO baseplate.

    • Connect Buttons to Pin 1, Pin 2, Pin 3, and Pin 4. Each will also connect to Ground (GND).

    • The Piezo will connect to Pin 8 and to Ground (GND).

    • You'll notice the Ground on the Bit Board (as well as the Piezo, Buttons, and other Crazy Circuits components we'll use) is color coded White.

  2. If you've never used a micro:bit before you'll want to check out this guide:  Bit Board V2 Setup and Use
    • If you've never used a micro:bit before you'll want to check out this guide: Bit Board V2 Setup and Use

    • We're going to load the following code for our Piezo Siren Function program: https://makecode.microbit.org/_gVL7LmV7j...

    • The micro:bit (since the release of version V2) has included a built-in piezo speaker on the back. You can use the built-in Piezo on a V2 micro:bit or connect a Crazy Circuits Piezo with Maker Tape as we've shown in this guide.

    • We will still play a unique siren sound with each button press, but this time we'll use a function we can easily call with different parameters.

    • Functions are a great way to make modular code and prevent having to use many blocks of code that are the same except for the values.

    • Once the code is loaded it should start running immediately.

    • You can power the micro:bit via the USB cable you used to load the code or you can use a battery pack plugged into the Bit Board.

    • Each button will play a different siren sound with slightly different parameters. (Thanks to our playSound function!)

    • Follow along with our recorded Live Stream!

    • You can watch the full video of us walking through this project, along with explaining and exploring the code: https://youtube.com/live/c5Dt9VZ0Rnk

Finish Line

Pete Prodoehl

Member since: 3/4/20

1,840 Reputation

424 Guides authored

0 Comments

Add Comment



View Statistics:

Past 24 Hours: 0

Past 7 Days: 1

Past 30 Days: 3

All Time: 40