Keyestudio Smart Little Turtle Robot V3 Manual page 89

Table of Contents

Advertisement

www.keyestudio.com
delay(15);
}
}
//function to control servo
void procedure(int myangle) {
pulsewidth = myangle * 11 + 500; //calculate the value of pulse width
digitalWrite(servoPin,HIGH);
delayMicroseconds(pulsewidth);
width
digitalWrite(servoPin,LOW);
delay((20 - pulsewidth / 1000)); //the cycle is 20ms, the low level last for
the rest of time
}
//****************************************************************************
Upload code successfully, servo swings back in the range of 0° to 180°
There is another guide for restraining servo---- servo library file, the
following link of official website is for your reference.
https://www.arduino.cc/en/Reference/Servo
//The duration of high level is pulse
89

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents