Building a Multi Micro:bit displayDavid MaddisonBlockedUnblockFollowFollowingFeb 26Micro:bit screens are a bit small, but how hard would it be to get several Micro:bits working together to form a much larger display.
That’s what I set about to find out in my latest project, a self organising, multiple Micro:bit animation display.
The first thing to work out is how the animation is going to work.
In this project I have one Micro:bit, the Master, that will be driving the animation, with the rest of the Micro:bits acting as slaves.
The Master bit will first draw the frame to be displayed into an ‘animation buffer’.
This is represented by a 2 dimensional array with one entry for every LED that’s going to be used.
So for a display of 3 Micro:bits, that will be a 5×15 arrayAfter updating the animation buffer, the master then splits the buffer into Micro:bit sized chunks.
Each chunk of data is sent to a specific Micro:bit telling it what to display.
To send the data to each Micro:bit the Master bit first needs to take the 5×5 chunk and encode it into some way that the slave bit can reconstruct.
There are many ways that this 5×5 chunk of data can be represented but given the timing and the small Micro:bit CPU it needs to be fast.
In this particular project I decided to keep the coding simple.
Encoding the 5×5 array is done by taking each row and adding the next row to it to create a long string of numbers, which in this case would be 25 numbers long.
Decoding is simply matter of cutting the string into strings of 5 numbers and reconstructing the original array.
With any animation, timing is important and that very much applies when using multiple displays.
Here we need to keep ALL the displays synchronized, otherwise we could end up with a Micro:bit showing it’s display early or late, resulting a bad looking animation.
Again, I decided to keep things simple and exploiting the fact that radio is broadcast to all Micro:bits.
It works by each Slave bit waiting for the data it should display next.
When it gets that data it then waits for a ‘render’ command from the Master before it displays the new screen data.
It’s not a perfect system since we can’t guarantee how fast each bit will get the render command and it probably wouldn’t work for a really fast animation but for our purposes it’s good enough.
The big question left unanswered is HOW each screen gets it’s position number and how the Master bit knows how many displays there are.
This was a tricky problem to solve because the Micro:bit has no location capabilities.
The solution was to use a combination of both physical connections so that each Micro:bit knows it’s neighbour and radio for the transmission of more complicated data.
All the Micro:bits are connected together in a chain with PIN0 connected to the previous Bit and PIN1 to it’s next neighbour.
It works like this:The Master bit sets PIN 1 high which is connected to the next Slave bit’s PIN 0Slave bit is waiting for PIN 0 to go high which triggers it to broadcast a “Need Number” messageMaster picks up “Need Number” message, increments it’s local count of screens and sends back a “Number Assign” messageSince ONLY the Slave that sent the message is waiting for the number, it retrieves the number and records it locallySlave then sets it’s PIN 1 high, triggering it’s neighbourThis continues with each Slave being triggered one after the other.
The last Slave is connected to PIN 0 of the master, so as soon as the Master bit has PIN 0 set high, it knows that all the displays have been registered and can start the animation loop.
When all Micro:bits are initially turned on they are in Slave mode but by pressing Button A on one of the Micro:bits it tells it to switch to Master mode and start the registration process.
So, to answer my original question, it’s not THAT difficult to get the Micro:bits working together thanks to the radio, but it was certainly a lot more work getting the animation loop and the display discovery working than I was expecting!All micro Python code is available on GitHub at https://github.
com/maddisondavid/microbit/tree/master/multidisplayThe video shows the displays starting up with the auto detection of order and then finally the resulting animation.