Home > other >  Delay in the Arduino () function of numerical limit? A novice for help
Delay in the Arduino () function of numerical limit? A novice for help

Time:09-16

#include

Servo myservo;//create Servo object used to control the Servo motor

Int pos=0;//store servo motor variable information from the Angle of

Void setup () {
Myservo. Attach (9);//Servo object connected to the 9 pin
Serial.begin(9600);
}

Void loop () {
For (pos=0; Pos & lt;=180; Pos +=1) {//0 degrees to 180 degrees
//1 degree per step
Myservo. Write (pos);//tell servo motor to achieve 'pos' point of view of variable
Serial. Println (pos);
Delay (15);//wait 15 milliseconds to ensure that the servo motor can reach the target Angle
}
For (pos=180; Pos & gt;=0; Pos -=1) {//180 to 0 degrees
Myservo. Write (pos);//tell servo motor to achieve 'pos' point of view of variable
Serial. Println (pos);
Delay (15);//wait 15 milliseconds to ensure that the servo motor can reach the target Angle
}
}

Above is my Arduino to control steering gear on the web site to see the running program, I tried, I found my steering gear cannot achieve 0 to 180 degrees of rotation, but in convulsions,,, then I put delay (15) delay time changed, found that more than 300 can be achieved, so that's why delay time is too small can't work? The somebody else's 15 ms can, models for DS3115 steering gear
  • Related