Friday, 25 August 2017

Getting Started with Kitronik MOVE Mini - Part 1

Those lovely people at Kitronik sent me one of their cool MOVE Mini kits to play with.

This morning I went through the initial steps to partially build the kit and test it. The kit is not fully assembled yet, but I do have the micro:bit connected to the PCB and the servos connected, with their wheels attached.



The Kitronik web site provides details of the code you need on your micro:bit if you want to control it from a smartphone using Bitty Controller. There's also a ready made hex file available from the Kitronik web site which you can download, if you just can't wait to get started.

Initially I had no success at all. I got no response from Bitty Controller and so had to back-track and troubleshoot.

The most important thing to do in this situation is to eliminate Bluetooth completely and check that the electrical connections between the kit's PCB, the micro:bit and the servos are all properly in place. In the Kitronik booklet, they provide guidance on testing the servos in Step 4. I implemented this code in MakeCode  but made one change, which was very useful. The code lets you start the servos running in either direction, by pressing micro:bit buttons A or B or make them stop by pressing A+B together. If these tests do not work, then you have a problem with the construction or electrical connections of your Kitronik kit. There's no point trying to control it over Bluetooth if this is the case and you need to track down the problem and fix it, perhaps disassembling and reassembling carefully, before trying the servo test again.

Watch this video to see the servo test in action:



The change I made to the servo test code was simply to display something on the micro:bit LED panel. The presence of the expected LED pattern confirmed that the micro:bit was receiving power from the batteries connected to the MOVE mini PCB. I'd definitely had problems with electrical connectivity earlier on, so this was a very useful change. Here's my code, from the JavaScript view of MakeCode, by the way.

basic.forever(() => {

})
input.onButtonPressed(Button.A, () => {
    pins.servoWritePin(AnalogPin.P1, 180)
    pins.servoWritePin(AnalogPin.P2, 180)
})
input.onButtonPressed(Button.B, () => {
    pins.servoWritePin(AnalogPin.P1, 0)
    pins.servoWritePin(AnalogPin.P2, 0)
})
input.onButtonPressed(Button.AB, () => {
    pins.servoWritePin(AnalogPin.P1, 90)
    pins.servoWritePin(AnalogPin.P2, 90)
})
basic.showIcon(IconNames.SmallDiamond)

There's a hex file compiled from this code available for download from the Bitty Software web site. Install it if you're having problems and check that micro:bit buttons A, B and A+B have the expected effect.

Once I'd sorted out connectivity glitches, I installed the ready made hex file for Bluetooth control which I'd downloaded from the Kitronik web site.

It didn't work.

It dawned on me that perhaps the hex file required me to pair my phone. Pairing is optional and whether you need to do it or not depends on the code from which your hex file was created. By default, MakeCode projects require you to pair.

Sure enough, this turned out to be the problem. Pairing requires a slight change to the usual procedure though, since you cannot access the reset button on the micro:bit when it's mounted on the kit PCB. Instead, switch off the kit PCB using its OFF/ON switch at the top,  hold down micro:bitbuttons A and B and then power the kit ON, keeping buttons A and B held down all the time until you see "PAIRING MODE!" scroll across the micro:bit display. Then use your phone's Settings/Bluetooth screen to select and pair (Android) or the nRF Connect application on iOS. See Bitty Software for videos demonstrating the basic procedure. Note though that you will not need to enter a 6 digit PIN. MakeCode specifies a simpler approach to Bluetooth pairing called "Just Works".

Here's a video showing me pairing with the micro:bit in my MOVE mini.


And here's my final test, involving Bluetooth and Bitty Controller!



No comments :

Post a Comment