Add the blocks (found at https://github.com/KitronikLtd/pxt-kitronik-servo-lite) in blocks editor (https://makecode.microbit.org/) to control the motors. You can do the same thing with writing to the pins, those instructions come with the build instructions, but using the extra blocks is a little easier to understand. Also add the package for neopixels (type in neopixels in the search box to find them). Two very good tutorials I found useful to start with can be found at:
- Neopixels on the robot in blocks - https://www.kitronik.co.uk/blog/using-kitronik-zip-leds-bbc-microbit/
- Servos on the robot in blocks - https://www.kitronik.co.uk/blog/kitronik-custom-pxt-editor-servo-blocks/
1. Motor example
I wanted it so that press A on the Micro:bit the robot goes turns right, goes forward, goes back and turns left.
A stop block does need to be included, without it the :Move will continue moving. The wheels I found can slip on some surfaces reducing the precision, but still fun to play with.
2. At the start and stopping.
I want to use the motors and the 'pixels', but I want to have a known starting position for the motors and set the turning speed; this was possible using the blocks (see below). The pixels are set at this point on pin P0 (see below) as well.
To stop both the motors and cycling of the pixels - pressing buttons A+B together was set up to this.
This is great fun. Having the set of blocks adding for the servos means it is a bit simpler to work with.
All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon