Keyestudio Ks0428 Manual page 96

Table of Contents

Advertisement

www.keyestudio.com
servo
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to
0 degrees
procedure(pos);
variable 'pos'
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);
pulse width
digitalWrite(servoPin,LOW);
delay((20 - pulsewidth / 1000));
level last for the rest of time
}
//********************************************************************
********
Upload code successfully, servo swings back in the range of 0° to
// tell servo to go to position in
//The duration of high level is
// the cycle is 20ms, the low
96

Advertisement

Table of Contents
loading

Table of Contents