Pages: [1]   Go Down
Author Topic: Reading acceleration and logging data to a file using gobetwino  (Read 427 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: July 01, 2011, 03:55:17 am by O_dana » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6893
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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... smiley 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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24327
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A useful, non-String way to do the conversion is to use "itoa"
Code:
char * itoa ( int value, char * str, int base );
Logged

"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.

Pages: [1]   Go Up
Jump to: