żěè¶ĚĘÓƵ

How to use a BBC micro:bit to make a sound-activated mirror ball

A BBC micro:bit program and a sound sensor will get the party started. Here's how to make a disco ball that automatically spins when music plays

New stuff you need

Continuous rotation servo

Sound sensor

micro:bit edge connector (optional)

Mirror ball

THIS week, it is time to get down and boogie, because we will be making an automated mirror ball. It will require two power sources, because components, like everything from evil geniuses to artists, crave power of different kinds in differing amounts.

Say you have a motor that needs at least 5 volts. The micro:bit board we have been using as the brain of our circuit needs only 3V. As we saw for LEDs, supplying more can cause damage. So if you want your micro:bit to control a motor, you can’t just wire them both to a heftier power source and hope.

Take your servo. It should have three wires: red, brown and yellow, ending in sockets. Connect the red wire to the positive power rail on your breadboard, and the brown wire to the negative or ground rail (blue), then connect the 9V battery to the rails to power your servo (you might need to cut a crocodile wire so one end can poke in the breadboard). The micro:bit has its usual 3V battery. Here is the important part: connect the ground rail to the micro:bit ground. Linking the grounds ensures both parts of the circuit cooperate.

Connect the yellow servo wire to pin 0 and finally add the sound sensor. To do this, connect “vcc” to the micro:bit’s 3V pin, “gnd” to ground and “out” to micro:bit pin 7. Pin 7 is the gold sliver to the left of pin 1. It is too skinny for croc clips so you can attach a wire with a blob of conductive paint or solder. Or I am using an edge connector, which lets your micro:bit slot into a breadboard with each pin to a row.

Plonk the mirror ball on the spinning part of the servo and glue it in place.

Now you are ready to code. For the sound detection, we need an “if \<true\> then else” block from the micro:bit editor’s “Logic” tab. Clip it into “forever”. Grab the “0 = 0” comparison out of the “Logic” tab too. Next, we want the advanced menu. Find “Pins” and grab “digital read pin”. This is going to check the output of the sound sensor. Stick it all together to make a line like “if digital read pin p7 = 0″, which basically means “if the sensor detects a sound”.

To move the mirror ball, you can use “servo write pin” to control the motor. Writing a value of 0 will spin the motor at full speed in one direction, and writing 180 will spin it in the opposite direction. Nestle this under “if”. Under “else”, stick another “servo write pin” and type 90. This makes the ball stop when the music does.

. Put on some tunes, point a torch at the mirror ball and you have a high-tech disco. (The sound sensor should have a dial you can turn to change the sensitivity.)

There is a lot more your motor can do. How about a winch for teabags – with a temperature sensor for optimal dunking? Let us know what you come up with.

To download a printable version of this page click here

Thanks to Imperial College Advanced Hackspace for use of their facilities

Ěý


For next week

Another continuous rotation servo

2 x wheels to fit servos

2 x long-arm limit switches

Battery box (to hold 4 x AA batteries)

Robot chassis or CD case

Ěý

Next in the series

1 Introduction

2 Electric candle

3 Toast notifier

4 Desktop traffic light

5 Propeller car

6 Magic 8 Ball

7 Theremin

8 Sound sensitive disco ball

9 Robot rubbish sweeper
Connect two motors for a roaming robot

10 Biscuit bot

Projects so far and a full list of kit required are at
Email: maker@newscientist.com

Topics: Electronics