Adding the Kitronik Packages to the micro:bit PXT Editor

kitronik micro:bit PXT tutorials

The BBC micro:bit is a low-cost and accessible way to introduce kids with drag and drop coding experience to integrating with hardware, eg robots and sensors, and start to solve more practical problems. If you've never heard of the micro:bit, check out our quick and simple explanation of the BBC micro:bit.

The BBC micro:bit PXT programming interface comes with a capable collection of blocks for coding with - these also allow access to send and receive data with accessories that can be attached to the micro:bit. This tutorial will show how to install extra blocks, in this case for the Kitronik servo:lite accessory board. Although it's important to understand how things work, using these blocks makes it easier for younger kids to get started getting robots and other creations moving in a short time.

The Default micro:bit Servo Blocks:

Behind the scenes, depending on the type, servo motors are moved set distances or speeds by varying the width of digital pulses sent to them (Pulse Width Modulation aka PWM).

In PXT, this translates to a fixed-distance servo moving a set amount, or a rotational servo moving a wheel at a certain speed.

The example below shows a fixed-distance servo:

In contrast, to turn a whole robot using rotational servos to spin the wheels, we must:

- drive one wheel at a certain speed for a certain amount of time;
- wait until the robot has turned;
- stop the wheel; 

This requires some experimentation to find the amount of time to wait eg wait x seconds for the robot to turn 90 degrees. Other factors to be considered include the design of the robot, the size of the wheels, etc. On more advanced robots, sensors can be used to check the robot's orientation and position.

Install Extra Packages in the PXT Editor:

Luckily, if you're using the Kitronik servo:lite board on your micro:bit, there's a package that can be added to PXT that includes a blocks that make this much easier. These can be used with other devices, with adjustment, but are configured for the kitronik servo:lite board; eg the turn speed is set to 200 degrees per second, by default. To add the package to PXT, click on 'Add Package':

 

Then type in 'kitronik' in the search field: 

 If you have the servo:lite board or a Kitronik :MOVE mini buggy, click on 'kitronik-servo-lite', which will install the following blocks under the 'Kitronik' item:

Kitronik servo:lite custom PXT commands added

 And that's it - now you can specify simple robot tasks in one block eg 'turn right 90 degrees'. Easy!

 


Newer Post