Koutarou Yabe
/
Servo_unlock
servo unlock
Fork of Servo_HelloWorld by
Revision 4:ea67df2060cd, committed 2017-05-08
- Comitter:
- dll7
- Date:
- Mon May 08 07:43:15 2017 +0000
- Parent:
- 3:e80efe31284d
- Child:
- 5:1f3b689130af
- Commit message:
- ??
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Mar 14 23:32:33 2017 +0000 +++ b/main.cpp Mon May 08 07:43:15 2017 +0000 @@ -7,37 +7,21 @@ InterruptIn button(D8); Serial pc(USBTX, USBRX); // tx, rx - -void rise(){ - printf("rise"); - servo = 0.0; -} - -void fall(){ - printf("fall"); - servo = 1.0; -} - int main() { - printf("Servo Calibration Controls:\n"); - printf("1,2,3 - Position Servo (full left, middle, full right)\n"); - printf("4,5 - Decrease or Increase range\n"); + printf("start Office Key system\n"); float range = 0.0005; - float position = 0.5; + + servo = 0.9; - while(1) { - switch(pc.getc()) { - case '1': position = 0.0; break; - case '2': position = 0.5; break; - case '3': position = 1.0; break; - case '4': range += 0.0001; break; - case '5': range -= 0.0001; break; - case '6': position += 0.1; break; - case '7': position -= 0.1; break; - } - printf("position = %.1f, range = +/-%0.4f\n", position, range); - servo.calibrate(range, 45.0); - servo = position; + servo.calibrate(range, 45.0); + while(true){ + pc.getc(); + servo = 0.3; + printf("open"); + printf("."); + wait(1); + servo = 0.9; + printf("close\n"); } }