BBC micro:bit
Microsoft PXT - Introduction


Microsoft PXT is the newest of the editors. It is made by Microsoft and is a natural step from the basic Block Editor. At frist glance, it looks very similar.

PXT Editor

Take a closer look and we can see a few differences. Firstly, there are two new visible categories of block. One of them is labelled Radio, the other Advanced. You can also see a link labelled JavaScript.


The following is a list of things that you can do with this editor that are not possible in the simpler block editor,

  • Write the exact same programs that you wrote in the old Block Editor.
  • See lovely icons on each block.
  • Change the range of values you get from the accelerometer.
  • Disable the LED matrix to free up some GPIO pins.
  • Work out the remainder resulting from a division calculation.
  • Convert a character code into a character.
  • Find the minium or maximum of two values.
  • Use the radio.
  • Create your programs in JavaScript.
  • Convert your code between blocks and JavaScript. Keep everything valid and you can move both ways.
  • Copy code into the JavaScript window, convert it into blocks and carry on editing that way.
  • Create events based on changes to the state of GPIO pins and specific values being sent.
  • Get the time in microseconds for a pulse signal.
  • Use the i2c and SPI pins.
  • Play a music pitch rather than a note.
  • Change whether GPIO pins use pull-up or pull-down resistors.
  • Read and write serial messages via USB or GPIO pins.
  • Write processes that are completed in the background.
  • Create microsecond-length pauses.
  • Use bluetooth functions.
  • Work with Neopixels.
  • Work with text files on the micro:bit.

This is quite a long list and is a massive upgrade on the functionality of the simpler block editor.

Some Benefits

The principle behind the development of this editor is to help people transition from using block editors into writing code for themselves. The switch between the JavaScript and the blocks makes this possible. If you were looking at an explanation of how to do something and only had the JavaScript, you can copy it into the editor and have it convert into blocks for you, making the program easier to follow. You also learn quite quickly that block editors are very time consuming to use. It works out way quicker to use copy and paste in the text editor and adjust the statements in the obvious places.

The additional features are the biggest boost. They allow you to work with different types of hardware with the block libraries making it relatively simple.

Microseconds are a very small unit of time. You'd be forgiven for thinking that this doesn't bring a lot to the party. Some components require specific signals to be sent within time frames that are this small. Being able to read microsecond pulses allows you to use range finders. Range finders are sensors to measure distance. At the affordable end of the market, you would pulse a trigger pin that sends out an ultrasonic blast. An echo pin is read and, based on the speed of sound, you can work out the distance to the object. Electricity moves pretty quickly. Microseconds are often all you need to wait - rounding everything up to a millisecond can throw off the timing of a program if you do it a lot.

Being able to run code in the background allows you to tie together animation and music. It's a bit more powerful than that though. For matrix displays and seven-segment displays, you need to have constant updating. Only a specific number of LEDs are on at any one time. With sufficiently small delays between the on/off switching, the LEDS look like they are on at the same time.

The additional Math blocks don't seem too impressive and, there is still a lot of stuff missing from here. They are useful however. The minimum and maximum blocks are a neat way to compare two items - much quicker than using an IF block. The remainder function is a nice extra - it is something you often need as a programmer.

The component libraries open up a lot of possibilities for you. Neopixels are bright and shiny things that are easy to connect and control if the code editor has a library of functions for you. There are some nice effects included in the libary. The i2c and SPI protocols are not the easiest things to use but are essential for working with complex components like RTCs.

The missing feature of the block editor part of this framework is being able to make your own blocks to carry out tasks you want to do often. You can write your own functions directly in the JavaScript editor. Once you do this, your code cannot be converted back to the block editor and you are stuck there unless you remove the function. This means the JavaScript editor is likely to be your final destination if you MicroPython doesn't have the functionality you want. At this point, you'd be doing this for the features, not the programming. MicroPython is a lot more flexible.