Reading acceleration and logging data to a file using gobetwino

Hi all,

this may sound stupid but how do you convert a integer into a string in arduino language?

I used in void loop the following:

int val6 = year();
String s1 = Integer.toString(val6);

And what I get is an error saying that:

" 'Integer' was not declared in this scope "

Is there something I'm missing? should I import some kind of library?

I did this before in processing and it worked but now it's just playing dumb.

Anyone knows how to do it? or has done it before and it worked for him?

Thanks! :cold_sweat:

Yeah,
I figured it out.
Arduino is not exactly like processing. So , if anyone else has this silly problem, the way to do it is:

val6 = year();
String s1 = String(val6);

That simple!

OD

O_dana:
Yeah,
I figured it out.
Arduino is not exactly like processing. So , if anyone else has this silly problem, the way to do it is:

val6 = year();
String s1 = String(val6);

That simple!

OD

That's one way to do it. Arduino is almost orthogonal to Processing except that arduino IDE has been a hack from Processing IDE. Arduino has very limited resource so you're not suggested to manipulate things with String class. You should instead learn to use char array to store string and do this:

int number;
char msg[20];
sprintf(msg,"%d",number);

I was very close to do that! But then it worked with the String command and I was happy enough to just finish that project!! Once and for all haha.

Since you responded... :slight_smile: Now I am using an accelerometer to make simple readings of x,y,z acceleration when the Arduino board is moved. The thing is that I am trying to log that data into a file. I downloaded Gobetwino (if you ever heard of it). Apparently it is supposed to log data onto a file. I can see it's reading everything from the arduino but I don't manage to make it write to a file. Do you have any idea what the commands in the Arduino sketch should be?

Thank you!

OD

A useful, non-String way to do the conversion is to use "itoa"

char * itoa ( int value, char * str, int base );