Go Down

Topic: Reading acceleration and logging data to a file using gobetwino (Read 488 times) previous topic - next topic

O_dana

Jun 30, 2011, 11:47 am Last Edit: Jul 01, 2011, 10:55 am by O_dana Reason: 1
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! :smiley-roll-sweat:

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

liudr


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);

O_dana

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... :) 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

AWOL

A useful, non-String way to do the conversion is to use "itoa"
Code: [Select]
char * itoa ( int value, char * str, int base );
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up