Adding Kitronik Custom MakeCode Editor Blocks:
At the time writing, we have three packages. They have been added directly to the Microsoft Makecode Editor and can be added in the same way that other Extensions are. Click the Cog icon in the top right of the editor and select 'Extensions' from the menu. This will open the Extensions window. Click into the search bar and type Kitronik then hit enter. The window should now look like the image below and you can make a selection from the available tiles. You will now have access to the blocks that you have chosen via the blocks menu. As can be seen with the Servo:Lite blocks shown below: Now that we know how to add them to the MakeCode Editor we’ll have a look at each block individually to see what they all do, most are as straightforward as they look but a couple warrant a little explanation. Either scroll down to the section of interest or jump straight there via the links below.The Servo:Lite Blocks:
Note: These blocks were written specifically for coding for the :MOVE mini buggy, however, if you are using 360 degree continuous rotation servos orientated in the same way as in :MOVE mini then the directional blocks will work in the same way. NOTE: A recent update to the MakeCode Editor included cosmetic changes. The blocks below now look slightly different but the still function in exactly the same way.
Allows the setting of the :MOVE mini forward/reverse speed. The allows tuning for the drive forwards and drive backwards x distance commands.
Turns right through the requested degrees and then stops. This needs the calibrate turn speed to x degrees per second tuned to make it accurate, as it uses a simple turn, wait, stop method. It also runs the servos at a slower pace than the right function to reduce wheel slip.
Sends servos to a neutral position. On a well trimmed 360 degrees servo this is stationary, on a normal 180-degree servo this is 90 degrees. This is especially useful for coding servos that will be performing tasks other than driving wheels, for example, a servo that is controlling a steering rack or part of a robot arm.
Stop for 360-degree servos, rather than write 90 as in the ‘goto neutral position’ block, which may or may stop the servo depending on how well trimmed it is. The Stop command literally stops sending pulses to the servo. On a normal servo, this will stop the servo where it is rather than return it to a neutral position, it will also not provide any holding force.
Turns through the requested degrees and then stops, needs NumberOfDegreesPerSec tuned make it accurate as it uses a simple turn, wait, stop method. Runs the servos slower than the turn left block to reduce the chance of wheel slip.
The Motor Driver Board Blocks:
NOTE: A recent update to the MakeCode Editor included cosmetic changes. The blocks below now look slightly different but the still function in exactly the same way. These blocks have been specifically designed to make coding the Kitronik Motor Driver Board for the BBC microbit as easy as possible. With the blocks below, you can control the direction and speed of each motor individually and also stop each one.
This block allows you to chose a motor, either one or two, and to instruct it to drive either forwards or backwards at a speed of your choosing. The range of values for speed are between 0 - 100.
The 16 Servo Control Board Blocks:
NOTE: A recent update to the MakeCode Editor included cosmetic changes. The blocks below now look slightly different but the still function in exactly the same way. Our 16 Servo Control Board for the BBC micro:bit allows for much more ambitious projects than are possible with our other motor and servo driver boards. With the single code block below, you can specify which of the 16 servos you wish to control and what angle you wish it to move to.
This block has a drop-down menu from which you can select any of the 16 servos that this board can control and it has an input area for you to type in the angle you require, from 0 - 180.
©Kitronik Ltd – You may print this page & link to it, but must not copy the page or part thereof without Kitronik's prior written consent.
8 comments
Mark Donnison
Hi, if you contact us at support@kitronik.co.uk we can try to help you with your work.
Ugo
Hi, I am on Crowdin with other acquaintances of mine. We are giving a hand to translate MakeCode blocks from English to French. We would like to translate the MotroDriver (2 blocks) and the ServoLite (12 blocks). Where can we find you? On Crowdin? Tks
Mark Donnison
Hej. Det är möjligt att kalibrera servon med kod. Det betyder att du inte behöver demontera den. https://www.kitronik.co.uk/blog/calibrating-360-degree-servos-move-mini/
Mark Donnison
The page has now been updated with the new blocks and with revised instructions with regard to how to add them. You’ll be pleased to note that they can be added from within the Makecode Editor as opposed to using the Git Hub link.
Mark Donnison
Hi Matthew, thanks for the feedback. This is on today's to-do list as we have released some new custom blocks, which requires that we update a few of our resources etc. Thanks again!
Matthew
The location of the code blocks you provide did not work, https://github.com/KitronikLtd/MakeCode-kitronik-servo-lite. However I tried https://github.com/KitronikLtd/pxt-kitronik-servo-lite and this did work. You might want to change the link on your web page.
Mark Donnison
Hi David, yes they can be used with other servos but you will need to take into account the following info. The code breaks out to P1 & P2 for use with the :MOVE mini kit. The servos will need a separate power supply to the micro:bit. We will be adding more blocks soon that will increase their usefulness for a wider range servo based activities.
David Held
Can the servo blocks be used without having your servo board?