Data Sheet

Microsoft MakeCode Blocks Editor Code
The program shown to the left was created using the Microsoft MakeCode Blocks Editor for the BBC micro:bit.
It enables the piano to play different notes through the on board speaker, depending on which keys are
pressed. The up/down function buttons currently just displays arrows on the BBC micro:bit display, but it
could be setup to allow the octave to be shifted up and down, meaning many more notes as keys would be
able to be played. The ‘key…is pressed’ produces a true or false value, depending on whether a particular key
press is registered. This means the block can be used with the ‘if…then’ and ‘while…do’ MakeCode blocks.
The program shown below was also created using the Microsoft MakeCode Editor. This is a simple starter
program which sets up the full piano in one block, but does allow the length of note played to be adjusted.
These blocks cannot be used with the ‘key…is pressed’ block.
There are also blocks which enable some of the capacitive touch chip (AT42QT2160) settings to be changed.
Changing the key sensitivity alters how sensitive the touch keys are (the higher the sensitivity value, the
greater the sensitivity).
Changing the noise threshold enables the touch sensor to cope with differing levels of background electrical
noise (the higher the noise threshold value, the more electrical noise it can cope with).
Note: These programs use the Kitronik :KLEF Piano package available on Microsoft MakeCode (the green
blocks shown here).
:KLEF Piano for BBC micro:bit
www.kitronik.co.uk/5631