Voor Maarten
Dependencies: MODSERIAL Servo mbed
Diff: main.cpp
- Revision:
- 0:c41f256db1d4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 20 10:12:45 2017 +0000 @@ -0,0 +1,30 @@ +// 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); + } + } +} \ No newline at end of file