Skip to main content

10

Minor Versionm

by Joshua

Introduction

Add a distance sensor to your micro:bit powered Xylophone and play songs by waving your hands or running around.

Parts

No parts specified.

Video Overview

Featured Document

  1. If you haven't built a micro:bit powered Xylophone yet, start with our Xylophone guide.
    • If you haven't built a micro:bit powered Xylophone yet, start with our Xylophone guide.

    • If you want to check out another distance sensor project, or see more information on the sensor, see our Distance Display guide.

    • Once you have a working (micro:bit powered) Xylophone you can add your distance sensor.

  2. If you've build the micro:bit powered Xylophone from our previous guide you'll have a row of 8 push buttons that were used to trigger the mallet to play notes.
    • If you've build the micro:bit powered Xylophone from our previous guide you'll have a row of 8 push buttons that were used to trigger the mallet to play notes.

    • We're going to remove the first button, that is connected to Pin 1 because we'll be using Pin 1 to connect our Ultrasonic Distance Sensor.

    • You can remove all the buttons if you want to do a full conversion (or just skip adding them when you build your Xylophone.)

    • If you already have buttons it's easy to keep them in place if you want to switch back to button control later.

  3. Use the 4 jumper wires to connect the Ultrasonic Distance Sensor to the header pins on the Bit Board. We found that a few rubber bands and LEGO bricks work well to hold our sensor in place pointing in the right direction. (Tape can also work.)
    • Use the 4 jumper wires to connect the Ultrasonic Distance Sensor to the header pins on the Bit Board.

    • We found that a few rubber bands and LEGO bricks work well to hold our sensor in place pointing in the right direction. (Tape can also work.)

  4. Connect a USB cable to the micro:bit and then plug it into your computer. We'll be using makecode.microbit.org to program our board. It uses a simple drag and drop block interface.
    • Connect a USB cable to the micro:bit and then plug it into your computer.

    • We'll be using makecode.microbit.org to program our board. It uses a simple drag and drop block interface.

    • We're going to load the following code for our Distance Xylophone program: https://makecode.microbit.org/_aAC0vX4Rp...

    • Remember that when the USB cable is plugged in it will power the micro:bit but not the servos for the Xylophone, so you'll need to add a battery pack before it works.

  5. Once you've got your battery pack connected to the Bit Board you can test it out!
    • Once you've got your battery pack connected to the Bit Board you can test it out!

    • Try standing at least half a meter in front of the distance sensor and then walking slowly towards it (or just run fast if that's your style!)

    • Try standing out of the line of sight of the distance sensor and lowering your hand at different distances... can you play a song?

Finish Line

Attached Documents

Pete Prodoehl

Member since: 03/04/2020

281 Reputation

278 Guides authored

0 Comments

Add Comment

View Statistics:

Past 24 Hours: 1

Past 7 Days: 2

Past 30 Days: 7

All Time: 266