Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 6 months ago.
Using Text LCD with Nucleo F401RE
Hi! I'm currently trying to use a LCD screen with my mbed Nucleo F401RE. I've tried testing it with a simple "Hello World " with the TextLCD library, but it keeps displaying wrong characters (" llo World! 1"). I've tested the wiring several times and also tried switching display.
Thanks for your help .
1 Answer
9 years, 6 months ago.
So which library are you using?
Please post the code also. Looks like the wiring is OK since the display is initialised and shows some good text. Could possibly be a problem with printing too soon after a clearscreen command that has not yet finished or printing a string that does not end with 0x00 since you get some more chars after "Hello World!" or is the extra '' 1'' part of your string?.
Hey; thanks for answering. I'm using the TextLCD library : https://developer.mbed.org/components/HD44780-Text-LCD/ After some time I understood what's wrong. To write a correct "Hello world" I wrote :
- include "mbed.h"
- include "TextLCD.h"
TextLCD lcd(PA_9, PB_10, PB_4, PB_5, PB_3, PA_10);
DigitalOut rw(PA_8);
int main() { lcd.cls(); wait(2);
lcd.locate(0,0); lcd.printf(" lo world! Hel");
while(1); }
The three last characters are displayed as the first, I don't know how to fix that .
I checked the pins in the TextLCD lcd and they are matching the table in the cookbook. Thanks again
posted by 20 May 2015Please use <<code>> and <</code>>
tags around your posted code to keep it readable.
#include "mbed.h" #include "TextLCD.h" TextLCD lcd(PA_9, PB_10, PB_4, PB_5, PB_3, PA_10); // RS, E, D4-D7 DigitalOut rw(PA_8); // RW int main() { lcd.cls(); wait(2); lcd.locate(0,0); lcd.printf(" lo world! Hel"); while(1); }
First make sure the RW pin of the LCD is at GND level. You can use a DigitalOut pin like so:
.. int main() { rw=0; lcd.cls(); etc..
but you can also simply hardwire the LCD RW pin to GND.
Just to make sure all pins are wired correctly, try to set the location to another line by calling lcd.locate(0, 1). I assume you are using the default 16x2 display (which type nr ?). Other displays may have different addressing schemes which confuse the lcd.locate().
posted by 20 May 2015