I have been programming for 20 years using BASIC, Pascal, assembly and recently Java but I have never needed to use C until the last week when I got an Arduino.
I have built a device using a 1280 with 4 line LCD, PS2 and IR interfaces and a few other bits and have written a program with a menu system that works but I have now spent more time on one silly little problem than on everything else and it is driving me loopy!
GLCD.Puts(variable); does not work for strings only arrays of chars.....
I have been pointed towards using the RC2 of the latest library but cannot find where that is.
I have been trying to use toCharArray again with no luck
I have tried writing a function to do it but again with no luck....
This is a function I wrote:
void printstring(String toprint){
char outputstring[255];
int i = 0;
while (i <= toprint.length() -1) {
if (i>255) {
i = 255;
break;
}
outputstring[i] = toprint.charAt(i);
i++;
}
outputstring[i] = 0;
GLCD.Puts(outputstring);
}
and I want to drive it with
String test = 'xxxThis is a test';
printstring(test);
I appreciate it is not very efficient etc but something that works would be better than something that is pretty!
When I run this code instead of displaying "xxxThis is a test" it displays "29556" !! I assume that this is the address of the string rather than it's value.
I have read the documentation but I still cannot fathom what * is in relation to char arrays either.
This is going to be one of those really newbie questions but I am really banging my head against the wall and it is holding up the whole project!