1 Output Input


Logic should dictate that input comes before output but the children find it more motivating to begin by making something happen. Output has the added benefit that the scripts are simpler to create and understand.

The micro:bit has a number of built in sensors that can be used for data input as well as two 'push to make' buttons labelled A and B.

The row of brass tabs along the bottom edge of the micro:bit are for connecting electrical components and circuits to the micro:bit so that it can read data from electrical components or write data (in the form of an electrical voltage) to them.

There are 5 big tabs with 4 mm terminals and 20 smaller tabs. When coding, these tabs are referred to as 'pins'.

(see Connecting the LED below)


Light an LED connected to pin 0

The model:

Connections can be made with 4 mm 'banana' plugs, 4 mm spring connectors or crocodile clips. The picture below shows an LED (and protecting resistor) with the positive side (red wire) being connected to pin 0 and the negative side (black wire) connected to GND.

See the Practical tips page for advice on making electrical circuits.



if button A is pressed

turn pin 0 on

display a message to say 'pin 0 on'

pause for 1000 milliseconds

turn pin 0 off

MakeCode Editor script:

It is not essential to display the message "pin 0 on", but for the beginner, it is reassuring, when things do not work as expected, to know that the file has been successfully downloaded to the micro:bit and is running.

BBC Block editor script:

Touch Develop script:

EduBlocks script:


An input is used to add some form of data to a program as it runs. For control purposes the input may be a switch being switched on or data entered via some form of sensor. The data may be digital (on/off) or analogue (a range of voltages).


Respond to a digital input to pin 2.


repeat the following forever

display the message 'press pin 2'

if pin 2 is pressed then display the message 'pin 2 pressed'

The scripts below will continue to display the message 'press pin 2' and to check if a connection has been made between 3V and pin 2.

If a connection has been made the message 'input 2 on' will be displayed.

There are lots of different ways to make a connection between 3V and pin 2. A simple push to make switch is the easiest as shown in the picture.

MakeCode Editor script:

BBC Block editor script:

Touch Develop script:

Micro Python script:

from microbit import *

while True:

display.scroll("press pin 2")

if pin2.read_digital () == 1:

display.scroll("pin 2 on")