![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Servo
Dependencies: mbed MODSERIAL Servo FastPWM
main.cpp
- Committer:
- AnkePost
- Date:
- 2019-10-11
- Revision:
- 2:381007cb7a70
- Parent:
- 1:f6898c9b8c44
- Child:
- 3:91b8945b659d
File content as of revision 2:381007cb7a70:
#include "mbed.h" #include "Servo.h" Servo myservo(D5); Serial pc(USBTX, USBRX); int main() { float range = 0.0005; float position = 0.5; float state = 0.1f; pc.printf("I am on\n"); myservo.calibrate (range, 90.0); while (1){ pc.printf("start new!"); myservo = 0.5; wait(1); state = myservo.read(); pc.printf("Current: %.5f \n", state); state = 0; wait(1); myservo.position(-45); wait(1); state = myservo.read(); pc.printf("Current: %.5f \n", state); state = 0; wait(1); myservo.position(0); wait(1); state = myservo.read(); pc.printf("Current: %.5f \n", state); state = 0; wait(1); myservo.position(30); wait(1); state = myservo.read(); pc.printf("Current: %.2f \n", state); state = 0; wait(1); myservo.position(45); wait(1); state = myservo.read(); pc.printf("Current: %.2f \n", state); state = 0; wait(1); myservo.position(90); wait(1); state = myservo.read(); pc.printf("Current: %.2f \n", state); state = 0; wait(1); } }