Introduction: STM32F103: Interfacing LCD 16x2 (using Mbed.h)

In this tutorial, we will be interfacing a commonly used 16x2 LCD with our Nucleo Board. we will be using mbed online compiler.

This Tutorial Contains following Steps:

  1. Setting up Hardware
  2. Coding using mbed
  3. Visualizing the output

Components Required:

  1. Nucleo Board (like STM32F103RBt6) with a cable to connect to PC
  2. 1x LCD 16x2
  3. 1x Potentiometer
  4. Bread Board
  5. Male-Male Wires

Step 1: Setting Up Hardware

Make Potentiometer connections as stated below:

  1. Pin 1 -> +5V
  2. Pin 2 -> Output (LCD V0/Vee)
  3. Pin 3 -> GND

Make LCD Connection as stated below:

  1. LCD Rs -> Nucleo A0 (PA0)
  2. LCD E (en) -> Nucleo A1 (PA1)
  3. LCD D4 -> Nucleo A2 (PA4)
  4. LCD D5 -> Nucleo A3 (PB0)
  5. LCD D6 -> Nucleo A4 (PC1)
  6. LCD D7 -> Nucleo A5 (PC0)
  7. LCD RW -> GND
  8. LCD A -> +5V
  9. LCD K -> GND
  10. LCD Vss -> GND
  11. LCD Vdd -> +5V
  12. LCD V0/Vee -> Potention output


  1. You can use +5V and GND of your Nucleo Board.
  2. No need to Solder wires to Potentiometer, you can just plug your potentiometer into your Bread Board.

Step 2: Codeing

Open up and Sign In to mbed Compiler. Click NEW. Make sure that NUCLEO-F103EB Platform is selected. From template, select Blinky LED Hello World. Enter Program Name and click OK. Now, right click on your program name folder and click select Import library->From Import Wizard. Now, Search For TextLCD. Select library whose Author is Simon Ford. Drag it and Drop it onto your program name folder. Now, open main.cpp file and remove all the code written there.

#include "mbed.h"
#include "TextLCD.h"
DigitalOut myled(LED1);
TextLCD ark(PA_0,PA_1,PA_4,PB_0,PC_1,PC_0);
int main()
    float i=0.0;
    while(1) {

Compile and Download the .bin file to Nucleo Board.

Step 3: Visualizing the Output

Now, that if you have made connection correctly and flashed .bin file onto your Nucleo Board, you must be able to see ARK4579 printed first Row of your LCD and a continuously increasing float value on second line.


  1. If you getting on output on the screen try adjusting the contrast.
  2. If your LCD is not showing anything, Connect LCD RW to +5V and then to GND and then press that BLCK button (RST btn) on your NUCLEO board.