It's been impossible to run Code Clubs and so on in these COVID-19-y times. However, I've just volunteered for a series of online Code Clubs with the Oxford Science Centre, and I thought I'd do something to introduce myself. What better than a scrolling message hat??
A simple idea - an array of microbits that scroll a message.
V1
Set up a displayString with the message to display. Assign each microbit an ID (1 -> n-1, string of length n), then using "radio send number", have the first (0) microbit send the index of the letter it's displaying to the others. They then subtract their ID to get the index of the letter they should be displaying, and display it.
- MB 0 - Forever; For index = 0 to displayString.length -1; radio send number index; show displayString[index]; end For; end Forever
- MB >0 - On radio receive number; If number - ID >=0 show displayString[number - ID]
OK... but it doesn't let the message tail off the display on the repeat, which is uncool, because the received number goes below the ID again!
Important point: I had to make sure I did "radio send index" before starting to display the current character, otherwise the later microbits in the chain didn't get the message until the first microbit had moved on :-/.
V2
Added some code to check if anything has been displayed yet, and if not, use number-ID to check for displayability; if previously displayed something, then use (number+displayString.length-ID) mod displayString.length to determine what character to display.
V3
It was really boring having N versions of the code to get a different ID into each microbit. So I used "press button A N times" to set the ID, and "press button B" to indicate I'd finished configuring the ID. The main loop and on radio receive number code were prevented from executing until the ID was configured by using a "readyToGo" boolean that was set to TRUE by the "press button B" code. Nice. Easy to have 10 microbits now!
V4
Having the same message all the time is really boring. I modified the scroller code to include "on radio received string" which would receive a new string, reset things, and start again, thereby changing the message.
I also created a "send new message" microbit, with an array of messages, selected by pressing button A repeatedly, and then pressing buttons A+B to send the radio message with the new string.
This seemed to be cutting the string short, and I eventually discovered that the maximum string length for radio send string is 19 characters, or I think 18+terminator. So keep those messages short!
 |
| The latest scroller code |
 |
| The current message setting code |
Possible enhancements
- Have all the messages in the scroller code, and have the ID 0 microbit do the triggering to all the others, so they use the identified message in the list; could be a timer or a number of repeats before changing; this avoids the radio send message length limitation
- The above, with a simple trigger microbit to tell them all to switch to the next or specific one. Nice for a stupid Stephen Hawking style message hat (simple words like Yes, No, Maybe, What?).
- With, say, 10 MBs, you could display individual words statically, or if too long, scroll them. Use an array of words rather than entire messages. That would be easier to read!