![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Servo
Dependencies: mbed MODSERIAL Servo FastPWM
main.cpp@8:3990a8c4ccea, 2019-10-28 (annotated)
- Committer:
- s1923196
- Date:
- Mon Oct 28 16:50:36 2019 +0000
- Revision:
- 8:3990a8c4ccea
- Parent:
- 7:464fb83c8cdf
- Child:
- 10:1754b6220c7a
servotesten
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnkePost | 0:60a8a60074a7 | 1 | #include "mbed.h" |
AnkePost | 5:74962b191242 | 2 | //#include "Servo.h" |
AnkePost | 5:74962b191242 | 3 | //#include "FastPWM.h" |
AnkePost | 5:74962b191242 | 4 | #include <math.h> |
s1923196 | 8:3990a8c4ccea | 5 | #include "Servo.h" |
AnkePost | 3:91b8945b659d | 6 | |
AnkePost | 0:60a8a60074a7 | 7 | Serial pc(USBTX, USBRX); |
s1923196 | 8:3990a8c4ccea | 8 | //PwmOut myservo(D5); |
s1923196 | 8:3990a8c4ccea | 9 | //DigitalIn servo_button_pressed(D0); |
AnkePost | 3:91b8945b659d | 10 | |
s1923196 | 8:3990a8c4ccea | 11 | Servo servo1 (D7); // kan nog aangepast worden de pin |
s1923196 | 8:3990a8c4ccea | 12 | //servo1.Enable(1500,20000); |
s1923196 | 8:3990a8c4ccea | 13 | int pos(); |
AnkePost | 3:91b8945b659d | 14 | int main() |
AnkePost | 3:91b8945b659d | 15 | { |
s1923196 | 6:e6125ef7705e | 16 | |
s1923196 | 6:e6125ef7705e | 17 | |
s1923196 | 8:3990a8c4ccea | 18 | while(1) { |
s1923196 | 8:3990a8c4ccea | 19 | for (int pos = 1000; pos < 2000; pos += 25) { |
s1923196 | 8:3990a8c4ccea | 20 | servo1.SetPosition(pos); |
s1923196 | 8:3990a8c4ccea | 21 | wait_ms(20); |
s1923196 | 8:3990a8c4ccea | 22 | } |
s1923196 | 8:3990a8c4ccea | 23 | for (int pos = 2000; pos > 1000; pos -= 25) { |
s1923196 | 8:3990a8c4ccea | 24 | servo1.SetPosition(pos); |
s1923196 | 8:3990a8c4ccea | 25 | wait_ms(20); |
s1923196 | 8:3990a8c4ccea | 26 | } |
s1923196 | 8:3990a8c4ccea | 27 | } |
s1923196 | 8:3990a8c4ccea | 28 | } |
s1923196 | 6:e6125ef7705e | 29 | |
s1923196 | 6:e6125ef7705e | 30 | |
s1923196 | 8:3990a8c4ccea | 31 |