sensors-based wireless controlled servo motors
I am working on a project that transmit several sensors data wirelessly between two xbee S2 and two arduino uno. the receiving xbee should use the received sensor data to control servo motors on a 6-dof robotic arm. I was able to transmit flex sensor readings and use them to control a servo motor, but how can I do that for several sensors, I mean how can I seperate between sensor readings such that each sensor is responsible for controlling a specific servo motor. Also, I am using a gyroscope with 3 dimentions (x,y,z), how can I transfer each dimention seperately such that the other end is able to know which is which.
Basically you are asking how to distinguish between different parameters that are all sent between the Arduino and Max via the serial bus, right? If that is correct, you should ask yourself what the data size of each parameter is. For instance, if you use 8 bits of data for a servo motor, that's still 256 steps which is pretty precise. So if all of your sensors and servo parameters are working correctly for an integer range of [0..255], then you can decide to put a 16 bit integer on the serial bus, where the first byte (first 8 bits) define the parameter (sensor 1, sensor 2, servo x, servo y, etc.) and the second byte (second 8 bits) are the actual value of this parameter. It's then just a bit of math and housekeeping to distinguish between different parameters.
Keep in mind that this is just one option of many. You can look into serial OSC, or make a string in Arduino code that's decoded again at the Max side of things. You can send "S1:42" as a string over the serial bus and have Max interpret this as "Sensor 1 currently has a value of 42",
HTH
try serial.print
your code need to make a serial.print per sensor
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
Hi
this is my preferred method, because it's both transparent and bulletproof (under normal conditions!)
(sketch included)
Brendan
. . . other methods do indeed exist, for example:
Try a forum search too, if you're interested in other methods.