malin
Dependencies: Servo mbed mbed-rtos
Diff: main.cpp
- Revision:
- 0:596de9a5c573
- Child:
- 1:da79761252bc
diff -r 000000000000 -r 596de9a5c573 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 30 11:01:49 2018 +0000 @@ -0,0 +1,29 @@ +#include "mbed.h" +#include "Servo.h" + +Servo Servo1(D6); +Servo Servo2(D7); + +int main() { + Servo1.Enable(1000,20000); + Servo2.Enable(1000,20000); + Servo2.Disable(); + for (int pos = 1000; pos < 1500; pos += 25) { + Servo1.SetPosition(pos); + wait(0.05); + } + for (int pos = 1500; pos > 1000; pos -= 25) { + Servo1.SetPosition(pos); + wait(0.05); + } + Servo2.Enable(1000,20000); + Servo1.Disable(); + for (int pos = 1000; pos < 1500; pos += 25) { + Servo2.SetPosition(pos); + wait(0.05); + } + for (int pos = 1500; pos > 1000; pos -= 25) { + Servo2.SetPosition(pos); + wait(0.05); + } +} \ No newline at end of file