Skip to main content

1.2

Major VersionM

by Pete Prodoehl

Introduction

The Bit Board Tank can take advantage of the built-in sensors found on the micro:bit, and we can use microphone to "remotely control" the Tank so it moves when it detects sound.

You might also want to check out our Tank - Light Activated guide which lets you control your Tank with a flashlight.

Video Overview

  1. For this guide you'll need a completed Tank Main Body.
    • For this guide you'll need a completed Tank Main Body.

    • You'll also need something to make sound! It could be your own voice, or a classroom full of clapping students.

    • You can also use a speaker playing a sound. (A Bluetooth speaker connected to a mobile phone or tablet works great.)

    • Our Sensor Showcase covers using the sensors built in to the micro:bit. The microphone is covered in Step 11.

  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 Tank Sound Detecting Simple program: https://makecode.microbit.org/_VbuMij5FX...

    • Note: This version of the code is a great starting point for this project. If you want to take it further examine the code for the Tank - Light Detecting Turner and consider using it for a starting point.

    • When you power on the Tank it will start moving while it runs a calibration routine to check for sound levels. (We'll cover the calibration in Step 3.)

    • Once the calibration is done the Tank will sit there waiting for the sound levels to go above the threshold that was set in the calibration routine...

  3. Make sure to see the note at the bottom of this step. We need to calibrate the sound levels in the room before the micro:bit can tell if there is a sound.
    • Make sure to see the note at the bottom of this step.

    • We need to calibrate the sound levels in the room before the micro:bit can tell if there is a sound.

    • The sound level can be anywhere between 0 and 255. (0 is very quiet and 255 is very loud.)

    • Our code takes 10 readings (with a slight pause between each reading) adds them all together and the divides by the number of samples (10 in this case) to get our final value.

    • Calibration routines often use this sampling technique where a number of values are captured and then the average of them is used.

    • Once we've calculated our ambient sound level we pad the number a bit to prevent false triggering. We used 35 for our pad value in this example but you can experiment with lower (or higher) values.

    • The calibration runs automatically when you power on the Tank but you can also run it by pressing the A Button on the micro:bit if you need to recalibrate.

    • Note: The Tank needs to move when it calibrates! This is because the motors make noise, and we need to take that sound into account when doing the calibration. The Tank's tracks can be a bit noisier that the Rover wheels.

    • Power on the Tank, and either set it down so it can roll, or hold it in your hand so the treads can move freely.

    • Do your best to be quiet and wait for the calibration to complete. Once the heart stops flashing on the micro:bit and you hear a second beep, the calibration should be done.

    • The Tank should be still when the room is quiet, so... Make some noise! Clap, yell, laugh... See if you can get the Tank moving.

    • You can make the Tank stop by being quiet. (Shhh!)

  4. The code provided should serve as a starting point for your own ideas about how the Tank can react to sound.
    • The code provided should serve as a starting point for your own ideas about how the Tank can react to sound.

    • You could program a sequence of movements and then try to control them by making sounds.

Finish Line

Pete Prodoehl

Member since: 03/04/2020

331 Reputation

280 Guides authored

0 Comments

Add Comment

View Statistics:

Past 24 Hours: 0

Past 7 Days: 3

Past 30 Days: 4

All Time: 46