I am attempting to pull data from a gps and print it to an lcd. Fortunately, there's lots of examples for using both gps' and lcd's, unfortunately, I am struggling with printing that information to the lcd.
I found an excellent (working) example that pulls data from the gps and prints it to the serial port using a printFloat function. I am attempting to take this function and convert it to instead return a char* that I can then send to the lcd. The problem I am having is that when I do the conversion I do not get numbers in my resulting string.
The best way to show my issue is to supply the code. Here is the code for the original function (which works):
And here is the attempt at converting the code (along with some debugging code) that I can't get to work:
and here is my test call (note, outputting to serial instead of screen right now):
As you can see with my last link to the calls to the functions, I basically call the working function (that just prints to the screen) and then the non-working function (that returns a string). The output to serial of each of these calls should be the same, but here is the output (including the debugging code you see in the second link):
Using printFloat:
Lat/Long(float): 10000.00000, 10000.00000
using char:
Lat/Long(float):
finishedChar after intPart: bbbbb
'
b
b,
finishedChar after intPart: bbbbb
'
bbb
My suspicions are with itoa() or strcat() not returning what I expect. Can anyone take a look at this and offer advice as to what may be going on?
hi im strugaling to get my arduino to type a key on the computer. i am new at using arduinos and i hear there are multaple steps involved but i dont have the slightest idea how to go about doing this. any code, info, tips would be helpfull. thanks.
What I need to do is create a char* from several floats. That is, I get the floats for lat and long from the gps and then I need to create a string based on it. It seems like the code I supplied via pastebin should work, but you can see I'm getting completely nonsensical results from it.
Do you guys have any suggestions on how to fix my code?
Thanks.
Edit: Oops, I had missed gbulmer's suggestion above. Thanks, I'll give that a shot tomorrow and see if it works any better.
Out of curiosity, do you happen to know why my code was not working?
Also, do you have a way for me to get a char*? If I put in, say char x[100] then when I call lcd.print() I'll get an error since it requires a char*.
intPartStr is a pointer to a character (or character array). What is it pointing to?
finishedChar is a pointer to a character (or character array). What is it pointing to?
Also, do you have a way for me to get a char*? If I put in, say char x[100] then when I call lcd.print() I'll get an error since it requires a char*.
I can't see a definition of lcd.print, but a simple way to get a char* from a char array:
char x[100];
lcd.print(&x[0]);
that is the address (a char *) of the first element in the array.
hi im strugaling to get my arduino to type a key on the computer.
This thread is not about that subject. Asking the same question over many threads will not help. Start a thread, ask the question as well as you can, and try to concentrate on that thread and help folks understand what you need.
Heh, I was just going to ignore the attempted thread jack
I'll give your suggestions a shot today and get back to you guys. Thanks.
PaulS: Ah, I see. It's been a while since I worked with a language where you can manipulate pointers directly, I'd misread what char* meant I'll rework the code today using your and gbulmer's suggestions. Thanks!