I have a project with 9 servo, I want to make a function to control each separate. Only that he is not accepting the servo as a parameter. Can someone tell me if it is possible to pass the servant as a parameter, and how? Thank you!! Example:
Servo s1,s2,s3;
void toMove(Servo obj,int inPosition, int forPosition){
var i = 0;
for(i = inPosition; i<forPosition; i++){
obj.write(i);
}
}
void loop(){
if(true){
toMove(s1,0,180);
toMove(s2,0,180);
}
}
var i = 0;
looks like JavaScript, not "Arduino code". – VE7JRO Jun 17 '19 at 23:54void toMove(Servo& obj,int inPosition, int forPosition){
– Juraj Jun 18 '19 at 5:15inPosition
toforPosition
in increments to the servo. Since the period of the pulsed signal to the servo is much longer (multiple orders of magnitude) than the time the for-loop needs, the servo will (almost) never see any intermediate values. You can just write theforPosition
to the servo. – the busybee Nov 15 '19 at 19:47