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.
11 years ago.
Help with printing strings to LCD please...
Hi all, I'm new to mbed. I have a LPC1768 and use an NXP LPCXpresso (OM13016) baseboard. I have successfully programmed the LCD "Hello World" program.
#include "mbed.h" #include "TextLCD.h" TextLCD lcd(p10, p12, p15, p16, p29, p30); // RS, EN, D4, D5, D6, D7 int main() { lcd.cls(); lcd.printf("NGX Technologies"); }
And I have been able to write some text on the second row too :)
But my next aim I just can't figure out. What I want to do is set up an array of various text strings, something like:
const string messages[] = {"First Message", "Message No.2", "Last Message"};
Then use something like this to toggle the messages:
lcd.printf(messages[i])
Where I could increment "i" via a counter or some other way. But when I compile I get an error saying: 'no suitable conversion function from "const std::string" to "const char*" exists'
I want to be able to write different pieces of text and just call the name of that text and an array of them would be preferable, like the 'messages[]' example.
My question is how can I print to the LCD a string from an array of different strings?
Any help would be great, but please, go easy on me. I am a beginner... Thanks Chris