Werkende servoaansturing, smooth met sinus
Dependencies: mbed Servo MODSERIAL FastPWM
main.cpp
- Committer:
- AnkePost
- Date:
- 2019-10-11
- Revision:
- 5:74962b191242
- Parent:
- 4:8ae0c82c2d60
File content as of revision 5:74962b191242:
#include "mbed.h" //#include "Servo.h" //#include "FastPWM.h" #include <math.h> Serial pc(USBTX, USBRX); PwmOut myservo(D5); int main() { myservo.period(0.02f); float t = 0; while (true) { float ref = sin(t); float pwm = 0.05 + 0.03 * ref; // maximale bereik: allebei 0.05 myservo.write(pwm); t+=0.02; // nooit groter dan periode servomotor, zelfde geldt voor regel hieronder wait(0.02); } }