Voor Maarten
Dependencies: MODSERIAL Servo mbed
main.cpp
- Committer:
- Jannes
- Date:
- 2017-10-20
- Revision:
- 0:c41f256db1d4
File content as of revision 0:c41f256db1d4:
// Continuously sweep the servo through it's full range #include "mbed.h" #include "Servo.h" #include "MODSERIAL.h" InterruptIn button3(D10); Servo myservo(D9); int k=0; //Other MODSERIAL pc(USBTX, USBRX); int main() { myservo.calibrate(0.005,60); pc.baud(115200); while(1) { for(int i=0; i<100; i++) { myservo = i/100; wait(0.1); float Posi = myservo.read(); pc.printf("\r Position = %.4f \n",Posi); } for(int i=100; i>0; i--) { myservo = i/100; wait(0.1); float Posi = myservo.read(); pc.printf("\r Position = %.4f \n",Posi); } } }