servo unlock

Dependencies:   Servo mbed

Fork of Servo_HelloWorld by Simon Ford

Committer:
dll7
Date:
Wed Jun 07 05:03:07 2017 +0000
Revision:
5:1f3b689130af
Parent:
4:ea67df2060cd
???????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 1:40d2fd0b99e6 1 // Hello World to sweep a servo through its full range
simon 1:40d2fd0b99e6 2
simon 1:40d2fd0b99e6 3 #include "mbed.h"
simon 1:40d2fd0b99e6 4 #include "Servo.h"
simon 1:40d2fd0b99e6 5
dll7 2:dd5776c8594d 6 Servo servo(D6);
dll7 2:dd5776c8594d 7 InterruptIn button(D8);
dll7 2:dd5776c8594d 8 Serial pc(USBTX, USBRX); // tx, rx
dll7 2:dd5776c8594d 9
dll7 2:dd5776c8594d 10 int main() {
dll7 4:ea67df2060cd 11 printf("start Office Key system\n");
dll7 3:e80efe31284d 12
dll7 5:1f3b689130af 13 float range = 0.0008;
dll7 4:ea67df2060cd 14
dll7 4:ea67df2060cd 15 servo = 0.9;
dll7 3:e80efe31284d 16
dll7 4:ea67df2060cd 17 servo.calibrate(range, 45.0);
dll7 4:ea67df2060cd 18 while(true){
dll7 4:ea67df2060cd 19 pc.getc();
dll7 5:1f3b689130af 20 servo = 0.2;
dll7 4:ea67df2060cd 21 printf("open");
dll7 4:ea67df2060cd 22 printf(".");
dll7 4:ea67df2060cd 23 wait(1);
dll7 4:ea67df2060cd 24 servo = 0.9;
dll7 4:ea67df2060cd 25 printf("close\n");
dll7 3:e80efe31284d 26 }
dll7 2:dd5776c8594d 27 }