I have a project where i have two servos that need to move in relation to one another.
How can i scale the outputs to reflect this.
im sending position in degrees and not microseconds.
Servo one has a range of 40 degrees to 140 degrees "Min Max"
Servo Two has a range of 10 degrees to 90 degrees "Min Max"
what i want to do is when i write a value to servo 1. i want to also take that value and write it to servo 2. but i want it to move in relation to servo one. so when i write a value to servo 1 it automatically adjusts this value to the appropriate position for servo 2 and writes it.
So when servo 1 is at 40 degrees. servo 2 is also at 10 degrees, both are at the bottom of their scales.
when servo 1 is at 90 degrees, servo 2 is at 45 degrees, both are in the middle of their scales.
when servo 1 is at 140 degrees servo 2 is at 90, or both are at the end of their scales.
and every number within.. it doesnt have to be exact, just close.
im not sure how to even address this. i seem to have it in my head that i can use constrain and map functions to do this. but so far i cant seem to wrap my brain around it.
running on a Arduino uno. any help is appreciated
this is how im writing position data to my servos
int pos1 = 45;
int pos2 = 0;
//somewhere in here i take the value of pos1 and modify it to be position2
pos1 = constrain(pos1, 40, 140);
pos2 = constrain(pos2, 10, 90);
Servo1.write(pos1);
delay(15);
Servo2.write(pos2);
delay(15);