The Micro:bit Monster Band
by 451Grader in Circuits > Microcontrollers
931 Views, 7 Favorites, 0 Comments
The Micro:bit Monster Band
This is mostly a programming instructable.
Since I made my first micro:bit sound I have wanted to make a project were each student could build and program their own micro:bit instrument and then they could be added together to form a band or an orchestra. I have since then build a number of micro:bit instruments, but it is first now I have taken the time to make the code that enables all the instruments to play at the same beat.
In this instructable I use 4 different instruments, but in theory you can use any amount. If is just importent that you only use one type of micro:bit. Using V1 and V2 together means that they will get out of rythm with each other.
I have also wanted to make some instructable for the elecfreaks micro:bit starter kit. Simply because I like the kit and think it is a good starter kit that allows you to build a lot of different stuff. So I decided to base my electronic build on that kit.
Supplies
Materials:
5xMicro:bit
5xBattery holders
10xAAA batteries
Cardboard
Some
10x3M 6mm screws
10x3M nuts
10xSpacers
Jumpwires (male-to-male)
Button
Mini-breadboard
Breakoutboard
Potentionmeter
Tools:
Drawing and painting tools. I use Posca pens
A scissor
Cable for programming the micro:bit
3M drill bit
Make the Band
So we start out by drawing the band members. the should be wider than a micro:bit.
I made some blob monsters that kind of looked like instruments, because it was easy and looked cool.
Remember to keep some space open in the button for the stands
Cut Out the Stands
Take you scissor and cut the cardboard in the button like on the picture, so that your cardboard can stand.
Make Holes
Now make holes in the cardboard for the micro:bit using the drill bit. Use the micro:bit to measure the distance.
Make 2 holes in each cardboard figure.
Install Micro:bit
Then use 2 screws to connect 2 spacers to each cardboard figure.
Afterwards use 2 nuts to install the micro:bit.
Add Battery
You should now be able to place the battery holder in the space betwen the cardboard and the micro:bit.
Then connect the holder to the micro:bit and the bandmember is finished.
Programming - Instrument
Now lets look at programming an instrument.
The Blocks will be in danish, since I am danish, but you can find the program here and it should hopefully be in your local language.
The start of the program is pretty simple.
We set the radio group to 1, so that the micro:bits can speak together.
Set the starting tempo to 120, so that they all have the same tempo
Then we set the two local variables to 0. Melodi controls the melody we play and Start is for synchronizing the beat.
Instrument - Reciving Instructions
This is the code for reciving commands.
We expect to get a word and a value.
Tempo will .change the tempo to the recived value and it should change the tempo for the entire band.
Start will make the micro:bit start playing its melody.
Now the next three changes the melody that the micro:bit play and you have 3 options
Band changes the melody for the entire band.
Instrument changes the melody for a group of instruments, so you can group several micro:bit together. Change "Instrument" to the name of the group the micro:bit is in.
Name changes the melody for individual instruments. Just remember to change "Name" to the name you want the micro:bit to have.
Instrument - Melody
This is the part of the program that runs the melody or beat.
As you can see it will forst start runing a beat when “start”=1. That is also how we syncronize the micro:bits. When we first turn on the instruments “start”=0 and so they will all just sit and repeatly so nothing. Then when they get the start signal they will all start playing the melody at the same time and with the same beat, so they will stay syncronized.
You can change the sound or when they play on the beat. You can also add a halfbeat at start and the end, to get the instrument to play on the off beat (Remember to remove a whole beat).
Building the Sender
Since we want the sending micro:bit to be able to control so many different functions, it make sense to build a small customable sender. You can upgrade it, to add more functions to your sender.
I am using the breakoutboard and small breadboard from the elecfreaks starter kit.
The button is connected to pin 0 on one side and Ground on the other side.
On 4 legged buttons 2 of the legs are connected. I use the two legs diagonal opposite of each other, because those two are never connected.
The trimpot is connected to pin 1 with the middle leg and the two other legs are connected to ground and 3V3.
It does not matter which of the side legs are commected to ground or 3V3.
Programming the Sender
You can find the program to the sender here.
On start we set the radio group to 1, so that the micro:bits can speak together.
Set the starting beat to 120, same as the tempo on the instruments.
Start is set to 0 like on the instruments for synchronizing the beat.
Since pin = is connect to ground through the button we want it to be pulled high, so that it registeres 1 when the button is not pushed and 0 when the button is pushed down.
Melodi is set to 0 and "Name" to 1, because that is the first name and the first melody.
Syncronizing the Band
This code is activated by pushing the small logo on the micro:bit.
The first time it runs, "start" will be equal to 0, so it will send "start" to all the instruments and set "start" to 0.
The send message will make all the instrument start playing the melody they got, at the same time, so they will be playing on the same beat.
Next time you press the small logo "start2 will not be equal to 0, so it will instead send "Band" 0. That will make all the band members play the 0 melody, which should be a melody with no sound in it.
Setting the Beat
This code first activates when the button is pushed down and pin 0 read 0.
Then it takes the value read by pin 1 and transform it to a number betwen 15 and 240. Then it send that number as the beat Tempo to the entire band, which ensures that the micro:bits stays syncronized even as the beat tempo changes.
The two first bits of code just enable you to change the value of melodi and name and show you the new value.
The third code, then send the current melodi number to the current name number. That allows different instruments to play different melodies.
This means that beat tempo, start and stop is done band wide.
While melodies can be choosen for each instrument.
Finishing Up
Now make different sounds, melodies and names for each of your instruments and download them to your cardboard figures and your band is ready.
The four instruments I used can be found as hex files below and linked to makecode:
Expanding the Project
In theory you should be able to use this code, to make a band of any size and you can also group instruments together.
Instead of the micro:bit just playing a sound. You should also be able to connect them to synthesizer or use motors or solenoids to hit on metal or glass to make sounds. The possibilities are endless.