My Cart:

0 item(s) - £0.00
You have no items in your shopping cart.

0

Kitronik Custom MakeCode Editor Servo Blocks

We’ve released several new robotics products recently that make use of servos and motors to provide movement. We recognised that creating code for the microbit to control these servos and motors can become time-consuming, especially if you are experimenting or re-purposing your robots projects regularly.

adding a servo
With that all in mind, we thought it would be useful to create some custom blocks for the MakeCode editor that anyone can use and that makes the job of coding these devices as quick and as painless as possible.

 

Adding Kitronik Custom MakeCode Editor Blocks:

We now have three packages that have been added directly to the Microsoft Makecode Editor that can be added to the editor in the same way as with other packages, such as neopixels etc.

Click the Cog icon in the top right of the editor and select 'Add Package' from the menu, this will open the Add Package window. Click into the search bar and type Kitronik then hit enter. The Add package window should now look like the image below and you can make a selection from the available tiles.

adding-custom-kitronik-blocks-make-code-editor-add-package-870

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:

kitronik custom blocks menu

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.

1

Allows the setting of the :MOVE mini forward/reverse speed. The allows tuning for the drive forwards and drive backwards x distance commands.

block image

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.

block image

Drives backwards the requested distance and then stops.

block image

Drives forward the requested distance and then stops.

block image

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.

block image

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.

block image

Turns right, call ‘stop’ to stop.

block image

Turns left, call ‘stop’ to stop.

block image

Drives backwards, call ‘stop’ to stop.

block image

Drives forwards, call ‘stop’ to stop.

block image

Allows the setting of the :MOVE mini turn speed. This allows tuning for the turn x degrees command.

block image

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.

 

For most applications, ie coding a remote control buggy, the Forwards, Backwards, Turn Right, Turn Left and Stop commands are all that should be required. However, if you are writing code for a drawing robot or a robot arm then you will need to calibrate turn speed and forward speed and use commands such as Turn left x degrees, which offers greater precision.

 

The Motor Driver Board Blocks:

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.

kitronik-custom-blocks-motor-direction

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.

kitronik-custom-blocks-motor-turn-off

This block allows you to turn off either motor.

 

 

The 16 Servo Control Board Blocks:

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.

kitronik-custom-blocks-16-serevo-control-board

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.

Materials, Perspex. Plywood, Polypropylene
← Previous Post Next Post →

9 thoughts on “Kitronik Custom MakeCode Editor Servo Blocks”

  • David Held July 1, 2017 at 2:25 pm

    Can the servo blocks be used without having your servo board?

    Reply
    • Mark Donnison July 5, 2017 at 12:15 pm

      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.

      Reply
  • Matthew December 24, 2017 at 10:21 am

    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.

    Reply
    • Mark Donnison January 2, 2018 at 9:48 am

      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!

      Reply
      • Mark Donnison January 2, 2018 at 2:29 pm

        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.

        Reply
  • micro:bot-robotar del 3: MOVE mini – Pedagog Trelleborg March 15, 2018 at 7:01 am

    […] Kitronik har (bra) egna PXT-paket att lägga till i editorn där koden för att definiera en sväng är extra trevlig. Smart! Beskrivning av dem hittar du här. […]

    Reply
    • Mark Donnison March 15, 2018 at 9:22 am

      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/

      Reply
  • Ugo June 28, 2018 at 8:34 pm

    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

    Reply
    • Mark Donnison June 29, 2018 at 11:26 am

      Hi, if you contact us at support@kitronik.co.uk we can try to help you with your work.

      Reply
Leave a Reply