robtillaart:
You might use the multimap - Arduino Playground - MultiMap - as I assume you have some non linear mapping for the ultrasonic sensors.
yes, this is true, i have some non linear mapping.... but first i want to make it to work in linear, just to test the hardware....
I am thinking about smthing like this:
int left, right; //lets assume this is the distance between the hand and the sensor in cm's
int %left, %right; //percentage
int redbull, jagermeister; //theese are the angles from 0 to 90 (corresponding to 0% and 100%) of the servo's
//lets assume that the distance of reading is from 6 cm and 20 cm
//so the left hand (20cm = 0%, 6cm = 100%), and right hand (6cm = 0% and 20cm = 100%)
//and on the servos 90 is closed and 180 is open
if(right=13) //right hand in the middle (13cm)
{
//the ratio is 1:1 so servos depend only on left hand;
servobull.write(180 * %left);
servojager.write(180 * %left);
}
if(right<13) //right hand goes bellow 13cm -->there will be more redbull than jagermeister
{
redbull = map(right, 12, 6, 90, 180);
jagermeister = map(right, 12, 6, 180, 90);
servobull.write(redbull * %left);
servojager.write(jagermaister * %left);
}
if(right>13) //right hand goes above 13cm -->there will be more jagermeister than redbull
{
redbull = map(right, 13, 20, 180, 90);
jagermeister = map(right, 13, 20, 90, 180);
servobull.write(redbull * %left);
servojager.write(jagermaister * %left);
}