I managed to focus some more time on tidying up my AI2 app for sending Mailbox messages via Bluetooth from my Android phone to an EV3. The EV3 code is really simple and looks like this:
The AI2 code provides two BT related buttons, Connect & Disconnect, a text box and a Go button to send the text:
When the text is entered and Go pressed it is sent as a Mailbox message with the name “beep” to the EV3, and displayed on its screen. The code to send it has to construct a message in the form:
MLenL, MLenH, 0x01, 0x00, 0x81, 0x9E, NLen, NameBytes, 0x00, TLenL, TLenH, TextBytes, 0x00
Which breakdown as:
- MLenL, MLenH = 16 bit little endian length of the rest of the message
- 0x0001 = Message counter
- 0x81 = System command, no reply
- 0x9E = Mailbox message
- NLen = 8 bit name length, including 0x00 termination
- NameBytes + 0x00 = The Mailbox name
- TLenL, TLenH = 16 bit little endian length of the text
- TextBytes + 0x00 = The Mailbox text
This in terms of code looks like:
If you would like to play with the code it’s available from my resources site at:
The code is released under the Creative Commons Attribution-ShareAlike 4.0 International License
At the Bricktastic event back in July I showed off my Plott3r as part of the Mindstorms exhibits. It was programmed to do the Hilbert and Dragon curves, several plot “files” and some other bits.
One of the questions that the kids kept asking was something along the lines of “can it write my name?” Unfortunately it wasn’t, and isn’t, capable of writing ad-hoc text. So since then I’ve been pondering ways of supplying user-provided text. I did consider an ultrasonic triangulated “keyboard”, but the US sensors got confused with each other’s signals – so for the moment I’ve put that idea to bed to be revisited in the future. My original thought, however, was “can I do this with a mobile phone?”
Since that original thought I’ve been looking at how to write an Android app that has a simple text box and “send” button. Kids are used to mobiles these days, so it seems to me to be the perfect UI. So far I seem to have settled on using MIT’s App Inventor 2. It does support EV3 to some extent, but I’m going to have to get down and dirty with the EV3 byte code to send mailbox messages via bluetooth 🙂
So, now I need to get learning how this AI2 system works. Thankfully they have tutorials, so I’ll be building the tilt/move tutorial soon to get to grips with communicating with the EV3. Tinkering with bytecode won’t be too daunting as I’m used to getting down to that level of bit twiddling via my current and previous jobs.
Nothing to show yet, but watch this space!