Go Down

Topic: Printing serial inputs to LCD (Read 760 times) previous topic - next topic


Hey all, I'm working on a project where I read in data from a UP-501 satellite chip and I want to display the data on an LCD screen. My problem is I don't know how to read data from the serial, save it as a string, parse the information, and print that information to the LCD.

I'm not a very good programmer so if you could please explain everything in detail I would appreciate it.

Data being received:

My goal is to read in that data through serial, and print out information to the LCD that looks like this:

Long: 6016.3245N
Latt: 02458.3270E
#sat: 10


My problem is I don't know how to read data from the serial,

Use Serial.available() to know how much data there is. If there is any, use Serial.read to read the next character.

save it as a string

Define a character array and an index. When you have data to store, store it in the position pointed to by the index and increment the index. Store a NULL ('\0') then. The string should be kept NULL terminated at all times, in my opinion. It MUST be NULL terminated before any string functions are called with it as input.

parse the information

Use strtok() (not strtok_r()). You may need/want atoi() and/or atof(), too.

and print that information to the LCD.

Depends on the LCD.

What you want to do is covered by the examples that come with the IDE. It is up to you to understand what each example does, and how to combine them into one usable sketch.
The art of getting good answers lies in asking good questions.

Go Up