I had one of these cheap 16 x 2 LCD display modules hanging around that I bought to go with some Arduino or Raspberry Pi project that I never finished – in fact I couldn’t get the thing to work at all.
So I’m delighted to have got it working with a micro:bit! Here’s what I used:
- 16 x 2 LCD module
- medium-large breadboard
- a whole heap of jumper wires, some male-male, some male-female
- a BBC micro:bit
- a Kitronik micro:bit breakout board
- a 5V power supply
- a 1KΩ resistor
I used this project as the basis, which includes a Python program to drive the display (registration required). You don’t need to download MicroPython to program a micro:bit, you can use the online editor – the beta Python editor will even allow you to flash programs straight to your micro:bit over webUSB if you’re using Chrome.
The wiring diagram isn’t very clear on that website, so here’s a list of all the pins on the LCD display and what you need to connect them to:
LCD pin | LCD function | connect to |
---|---|---|
1 | GND – 0v | GND on micro:bit & -ve 5v |
2 | 5v in | +ve 5v |
3 | Contrast | GND via a resistor |
4 | Register select | micro:bit pin 0 |
5 | Read/write | GND |
6 | Enable | micro:bit pin 1 |
7 | Data DB0 | not connected |
8 | Data DB1 | not connected |
9 | Data DB2 | not connected |
10 | Data DB3 | not connected |
11 | Data DB4 | micro:bit pin 8 |
12 | Data DB5 | micro:bit pin 12 |
13 | Data DB6 | micro:bit pin 2 |
14 | Data DB7 | micro:bit pin 13 |
15 | Backlight +ve | +ve 5v |
16 | Backlight GND | -ve 5v |
I tried driving the whole thing off the 3v supply on the micro:bit, but it didn’t work – I think you really do need an external 5v power supply as there has to be a bigger difference in voltage between the power in and the contrast pin (although perhaps someone can do something clever with this information?) I didn’t have one to hand, so I chopped an old USB lead in half, and stripped the wires back to get 5v off the red (positive) and black (negative) wires, which I connected to the +ve and -ve (GND) rails on my breadboard.
Normally you’d use a potentiometer to adjust the contrast, but I just used a 1KΩ resistor instead.
You’ll see in the video that I added a little switch as well to turn the backlight on and off and you’ll see below I found an old volume control or something which I’ve pressed into service as a contrast knob on my maximum / minimum temperature display:
Here’s the Python program that does the temperature display (not including the LCD driver code):
InitDisplay() def showTemp(): clear() showText('Current temp: ' + str(temperature()) + 'C') setCursor(0,1) showText('Max: ' + str(maxTemp) + ' Min: ' + str(minTemp)) currentTemp = temperature() maxTemp = currentTemp minTemp = currentTemp showTemp() while True: if currentTemp != temperature(): currentTemp = temperature() if currentTemp > maxTemp: maxTemp = currentTemp if currentTemp < minTemp: minTemp = currentTemp showTemp() sleep(1000)
It would be nice if someone made an adaptor to allow you to plug one of these common LCD modules straight into a micro:bit, with a USB input for 5v display power, maybe back-powering the micro:bit with 3v?
Now what else shall I do with it? Show received radio messages from other micro:bits, make another Little Box of Poems or other random fact dispenser?
Hola. Estoy tratando de usar display lcd I2C con microbit y programando en Python (create.whitcode.com o con python.microbit.org/v/1.1) pero no encuentro drivers para el lcd.
No hay documentación en español de como poder trabajar con Python. Tu puedes ayudarme?
Hola! Me temo que no hablo español, así que estoy usando DeepL para que me traduzca. El programa Python que incluye el’driver’ para la pantalla LCD está en esta página web: https://maker.pro/microbit/tutorial/how-to-setup-an-lcd-screen-with-microbit
Espero que eso ayude. Buena suerte! Giles
Thank you for this article.
How do I configure and drive the LCD?
Hi Aref – can you tell me a bit more about what you’d like the LCD to do?
I can’t get your program to work, I’m afraid. My 16×2 LCD has an i2c display, so I can’t put a contrast-controlling resistor in the circuit. However, the LCD lights up – on full power – so it could be working all along!
Any thoughts on how to change the contrast on an i2c setup, please?
regarding your request, try using a 10K penetrometer to control the contrast instead of the resistor
PS Some further research into the i2c boards attached to LCD displays shows that most of them have a small pot on the back – just for changing the contrast!
PPS Still doesn’t work, though – and I’ve checked the i2c is working on Ox27.
Strange – the ssd1306 program works fine!
I tryed program LCD using blocks with MakeCode but it did’t work.
I think reason is that LCD works on 5v but microbit board 3v so the logic level is different.