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:
- Setting up Hardware
- Coding using mbed
- Visualizing the output
Components Required:
- Nucleo Board (like STM32F103RBt6) with a cable to connect to PC
- 1x LCD 16x2
- 1x Potentiometer
- Bread Board
- Male-Male Wires
Step 1: Setting Up Hardware
Make Potentiometer connections as stated below:
- Pin 1 -> +5V
- Pin 2 -> Output (LCD V0/Vee)
- Pin 3 -> GND
Make LCD Connection as stated below:
- LCD Rs -> Nucleo A0 (PA0)
- LCD E (en) -> Nucleo A1 (PA1)
- LCD D4 -> Nucleo A2 (PA4)
- LCD D5 -> Nucleo A3 (PB0)
- LCD D6 -> Nucleo A4 (PC1)
- LCD D7 -> Nucleo A5 (PC0)
- LCD RW -> GND
- LCD A -> +5V
- LCD K -> GND
- LCD Vss -> GND
- LCD Vdd -> +5V
- LCD V0/Vee -> Potention output
NOTE:
- You can use +5V and GND of your Nucleo Board.
- 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() { ark.printf("ARK4579"); float i=0.0; while(1) { ark.locate(0,1); ark.printf("%f",i); i=i+0.5; } }
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.
Note:
- If you getting on output on the screen try adjusting the contrast.
- 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.
5 Comments
2 years ago
hi I am trying to open account with embed but my gmail is unable to receive verification mails. after doing a lot of research I found it needs some organizations mail id.
if there any other way for me to open embed account
reply fast
Question 3 years ago on Introduction
Hi,is this lcd connection works for stm32f411e discovery kit
4 years ago on Introduction
hi , I want to work with lcd 16*2 by cube mx and program one stm32f103c8t6 . please help to me . thank you very match
5 years ago
Will this work for any nucleo board for e.g. f303rb??
5 years ago on Introduction
Do i need to use some resistors like the ones in the foto ? If so what are there valor and to what pin's do i connect them ?