Introduction: Dual Colour Bar Graph With CircuitPython

About: Retired teacher of computing - started 1967 with FORTRAN IV. I now play with development boards such as Raspberry Pi, Pico, Arduino, micro:bit and Adafruit CircuitPython boards like the Insybitsy M4 and Circui…

I saw this LED bar-graph on the Pimoroni site and thought it might be an inexpensive and fun project while undertaking covid-19 lockdown.

It contains 24 LEDS, a red and a green, in each of its 12 segments, so in theory you should be able to display red, green and yellow. Normally you would expect 2 anodes, one for red and one for green, and 24 cathodes if you were building it out of 24 LEDs. This package only has 14 pins and three pairs of pins are connected internally!

How do you drive 24 LEDs with only 11 pins? This looked an even more interesting project.

· We will have to make use of the persistence of vision in the eye and flash the various LEDs very fast.

What do I want to be able to do with it?

· Move a single red, green or yellow light back and forth along the display

· Display a red, green or yellow left-aligned bar along the display

How can I supply a simple input to change the display?

· Use a 10K potentiometer to generate values from 0 to 12 inclusive.

I decided to use an Adafruit ItsyBitsy M4 Express for this project and program it using CircuitPython. This is a 3.3V device so I decided to put 330 Ohm resistors on the anodes to keep the current down and protect the microcontroller pins and the LEDs. I’m only going to light a maximum of two LEDs at any moment – a red and green LED in the same segment to obtain yellow.

Step 1: What Do We Need?

Bar-graph package

Itsybitsy M4 Express

Strip board or breadboard

3x 330 Ohm resistors

10K Ohm potentiometer

Jump wire

Jump leads

Mu editor to develop script and flash the microcontroller.

Step 2: How It Works

The display is split into 3 sections (Low – the left end, Mid – the centre and High – the right end), each containing 4 segments. Each section has a single anode powering 8 LEDs. The anode pins are connected internally. Pins 1 & 14 for Low, pins 6 & 9 for the Mid and pins 7 & 8 for High – you can use either. The red cathodes are pins 2,3,4 and 5, while the green cathodes are 13, 12, 11 and 10.

To switch on an LED the current must flow via a 300 Ohm resistor from a HIGH anode (3.3V) to a LOW (0V) cathode pin.

To make the leftmost segment RED:

anode pin 1 is set high while the other anode pins, 6 and 7 are set low (select section)


red cathode 2 is set low while all other cathode pins are set high (select LED)

To make the rightmost segment GREEN:

anode pin 7 is set high while the other anode pins, 6 and 1 are set low (select section)


green cathode 10 is set low while all other cathode pins are set high (select LED)

Step 3: Connecting Up the Parts

I used strip board but you could try a breadboard. See next page for photograph.

Step 4: Finished Board

I used the Mu editor to develop the code and flash it to the ItsyBitsy M4 Express.

Here is the code:


Step 5:

This video shows the finished project working. The yellow appear to be rather more orange than yellow, probably because the red LED is brighter than the green one. You could add small resistors to the red cathode links to reduce the red intensity.

I hope you will give it a go.