
New stuff you need
Advertisement
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
Battery box (to hold 4 x AA batteries)
Robot chassis or CD case
Ģż
Next in the series
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