Using a light sensor with BBC micro:bit and MicroPython

A light sensor is a small component with a particular characteristic: it is basically a resistor and its resistance decreases if the light is more intense. To use it with micro:bit we need to use one of the analogic ports. To build this circuit you will need a breadboard, 3 jumper wires, a 10k resistance and possibly a Kitronik breadboard kit.

The project

I wanted to realise a simple project where, depending on the light intensity captured by the light sensor, the micro:bit shows an image of the Sun if the light is intense and an image of the Moon if the light is less intense.

Here is the complete circuit scheme:


“Image Copyright © Kitronik”


and here is a picture of the finished project I created:


The source code I needed is available here:

and as a demo I realised this small video:

Prototyping BBC micro:bit projects with Kitronik breadboard kit

BBC micro:bit has a few IO pins that can be used to interact with external devices. The problem with the board is that it’s not easy to connect the classic jumper wires (those that we normally connect to a breadboard) to the micro:bit, unless using a crocodile clip and being limited to just 3 pins.

Kitronik breadboard kit solves this problem, offering an interface where the micro:bit can be plugged and all the pins are easily connectable to the breadboard using normal male/female jumper wires.

I’ve built a very simple circuit following an example you can find on this manual


To build the circuit you also need 4 male/female jumper wires and two buttons. All this circuit does is to connect the buttons to the micro:bit pins that relate to those buttons. Basically pressing those buttons is the same as pressing button A or button B on the micro:bit board. Here you can see the schema in detail:

Screenshot 2016-02-07 14.30.36

“Image Copyright © Kitronik”

I’ve also made a short video so that you can see it in action:

And of course the source code is available too: