Skip to content

Commit 1742fb1

Browse files
committed
fix #25
1 parent 9f8e1dd commit 1742fb1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/servo/servo.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ void setup() {
4646
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
4747

4848
delay(10);
49+
setServoPulse(7, 0.001);
50+
while (1) ;
51+
4952
}
5053

5154
// you can use this function if you'd like to set the pulse length in seconds
@@ -58,7 +61,7 @@ void setServoPulse(uint8_t n, double pulse) {
5861
Serial.print(pulselength); Serial.println(" us per period");
5962
pulselength /= 4096; // 12 bits of resolution
6063
Serial.print(pulselength); Serial.println(" us per bit");
61-
pulse *= 1000;
64+
pulse *= 1000000; // convert to us
6265
pulse /= pulselength;
6366
Serial.println(pulse);
6467
pwm.setPWM(n, 0, pulse);

0 commit comments

Comments
 (0)