sp+=dr;
if (sp>2000 || sp<1000) dr=-dr;
delay(1);
}
The problem is that the input data to move the servos is generated by Max/MSP. The communication with Arduino (Serial or OSC) it´s too painful; so I opted to use Processing to receive the OSC data from Max/MSP. Simply with 7 servos plugged to my Arduino Mega works with no problems (using ServoFirmata)
The shield´s creators says that the board is coded like an Arduino Mega anyway, I was wondering how to code in Processing to use it. I only have to declare the 48 pins and parse the data?
I was hoping to clear this matter before buying the board.
Any help will be appreciated¡
I hope I´m explaining properly, sorry about my bad english¡
The problem is that the input data to move the servos is generated by Max/MSP.
Not in that code, it isn't.
The communication with Arduino (Serial or OSC) it´s too painful
In what way? What IS Max/MSP sending to the Arduino?
so I opted to use Processing to receive the OSC data from Max/MSP.
But, you didn't show that code.
The shield´s creators says that the board is coded like an Arduino Mega anyway, I was wondering how to code in Processing to use it. I only have to declare the 48 pins and parse the data?
Yep. Forget using ServoFirmata, though. That doesn't support 48 servos.
Any help will be appreciated¡
I hope I´m explaining properly, sorry about my bad english¡
Your English is fine. Your code posting is not. Please modify your post, select the code, and select the icon with the # symbol on it. Then, save the changes. I presume you didn't really attach a servo to the smiley face pin.
Forget about Processing, now I´m trying to send one unique value from Max/MSP to Arduino by Serial; and then in Arduino parse them to the servos and delay them properly.
I´m starting from Communication examples; the part I don´t understand is about encoding data, Max sends an integer but Arduino gets a Byte... from the example I started encoded the entering values from 0 to 9; mapping these values to 0 to 180 (properly for servos) I get so small range. I Tried to amplify the proper range but they stop moving...
It´s a little smart iniciation, at least they move, but I need to control the degrees more properly, any ideas?
Thank you, and sorry, I´m pasting the code fine, n00b issues¡
Is Max sending that integer in binary or as text? If it sends 22 as a binary value, then the Arduino can receive that 2 byte value as a single byte (unless you are trying to dealt with servos that rotate more than 255 degrees) with no problem.
If Max is sending "22", then you need to fix what Max is sending, so the Arduino knows where the value ends. Otherwise, the Arduino has to deal with something like this:
IfMaxissending"22",thenyouneedtofixwhatMaxissending,sotheArduinoknowswherethevalueends.
Much harder, no?
from the example I started encoded the entering values from 0 to 9; mapping these values to 0 to 180 (properly for servos) I get so small range.
I don't understand this statement. The range stays 0 to 180, if you mapped stuff correctly. The resolution goes to hell, since your step size is now 20 degrees.
Since the map function you are using has as it's from range '0' and '9', I think it is obvious that Max is NOT sending binary data.
So, you need to make Max send something after the value (like we use spaces between words), so the Arduino can read and store any serial data that arrives, until the separator arrives, at which time it can use atoi() to convert the string "114" to an int, 114) and then move the servo(s).
Max could even send something like "2:109!" to tell the Arduino to move servo 2 to 109 degrees.