servo motor
Dependencies: mbed QEI Servo HIDScope MODSERIAL FXOS8700Q FastPWM
main.cpp
- Committer:
- IsaRobin
- Date:
- 2019-10-29
- Revision:
- 0:fd4dd111fbd9
File content as of revision 0:fd4dd111fbd9:
#include "Servo.h" #include "mbed.h" #include "MODSERIAL.h" #include "FastPWM.h" // PC connection MODSERIAL pc(USBTX, USBRX); int main() { pc.baud(115200); pc.printf("starting 1"); Servo myservo(D3); int pos1 = 1000; int posperiod = 20000; myservo.Enable(pos1,posperiod); while(true) { pc.printf("starting"); for (int pos = 1000; pos < 2000; pos += 25) { myservo.SetPosition(pos); wait_ms(20); } for (int pos = 2000; pos > 1000; pos -= 25) { myservo.SetPosition(pos); wait_ms(20); } } }