|
331
|
Using Arduino / Programming Questions / Re: PS/2 +Servo
|
on: April 01, 2013, 08:03:50 am
|
|
So as of right now, without the servos connected, the code works or it doesn't work? It code be something in the libraries that are conflicting with each other. Post your .h and .cpp files for the PS2 mouse.
|
|
|
|
|
336
|
Using Arduino / Programming Questions / Re: Strings, Char, and Arrays
|
on: March 30, 2013, 11:47:59 am
|
|
Your incoming string is going to be individual chars, not a full string. So like I said before, save the incoming chars into a char array and then split it up. As for the M117, you can use substrings, but will it work when you enter the string via serial monitor?
Note: it may need a terminating character.
|
|
|
|
|
337
|
Using Arduino / Programming Questions / Re: Strings, Char, and Arrays
|
on: March 30, 2013, 10:29:37 am
|
|
strtok() works like this.
your string "123,456:789." strtok will look in the string and actually look for ", : ." If strtok sees any of those characters, it will return to the first address it started from, and out put the data up to that split char. Now yours, being that it starts with a char and then the number follows, it will not work correctly. This is unless you maybe have a dummy variable, and then on the next variable you store the correct data. But it would just be easier to just send the numbers first and then the splitting char.
So from M117 to 117M
|
|
|
|
|
339
|
Using Arduino / Programming Questions / Re: Strings, Char, and Arrays
|
on: March 29, 2013, 05:21:12 pm
|
|
So why not just use strtok()? It will do everything practically for you. The only thing that it won't do, is look at individual incoming chars, it needs to be a complete string. So what you can do is, store everything first, then split the data.
|
|
|
|
|
344
|
Using Arduino / Programming Questions / Re: Weird problems with Wire.h
|
on: March 29, 2013, 11:52:01 am
|
Please fix this if (accelerationX > 500) control = B00000001; //tilt back if (accelerationX < -500) control = B00000010; //tilt forward if (accelerationY > 500) control = B00000011; //tilt right if (accelerationY < -500) control = B00000100; //tilt lfet if (accelerationX < 500) { if (accelerationY < 500) { if (accelerationX > -500) { if (accelerationY > -500) control = B00000000;}}} //back to blank state
For your last "control = B00000000" just use an ELSE statement. Next, why does stop() need to be in every movement? Also all those delays are going to make your code very sluggish. Look into the "Blink Without Delay" example, it will help you greatly.
|
|
|
|
|