Answer the question
In order to leave comments, you need to log in
Need Help Breaking Down the Code How to Reduce Servo Rotation?
void motion (char dimention, int prev_angle, int next_angle, int time)
{
int a;
if(next_angle>=prev_angle)
a=15;
else
a=-15;
if (dimention=='f')
{
int i=prev_angle;
while( i!=next_angle)
{
i+=a;
myservo.write(i);
forward();
delay(time);
}
}
if (dimention=='l')
{
int i=prev_angle;
while( i!=next_angle)
{
i+=a;
myservo.write(i);
left();
delay(time);
}
}
if (dimention=='r')
{
int i=prev_angle;
while( i!=next_angle )
{
i+=a;
myservo.write(i);
right();
delay(time);
}
}
if (dimention=='b')
{
int i=prev_angle;
while( i!=next_angle )
{
i+=a;
myservo.write(i);
back();
delay(time);
}
}
if (dimention=='w')
{
int i=prev_angle;
while( i!=next_angle )
{
i+=a;
myservo.write(i);
wait();
delay(time);
}
}
}
void front_motion( int time )
{
if(dist_45<=9)
{
left();
delay(3*time);
}
if(dist_135<=9)
{
right();
delay(3*time);
}
}
void motion_back( int time )
{
motion('b',180,90,2*time);
if(dist_l>=dist_r)
{
do
{
left();
delay(time);
dist_f=sonar();
}while(dist_f<=20);
}
if(dist_l<dist_r)
{
do
{
right();
delay(time);
dist_f=sonar();
}while(dist_f<=20);
} }
Answer the question
In order to leave comments, you need to log in
What do you need? Decrease the speed at which the servo moves from one position to another? Change the speed of a servo that is designed for constant rotation? You can do
it without delving into the program.
In the case of a constant rotation servo, this will reduce its speed, in this case by 2 times, in the case of a conventional servo, it will reduce its rotation angle by 2 times.
If it is necessary to slow down the movement and make it smoother, then apparently a decrease in the variable amyservo.write(i);
myservo.write(i/2);
a=15;
else
a=-15;
a=5;
else
a=-5;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question