Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
Servo/servo_bewegung.cpp@16:f0480e9c5039, 2021-04-21 (annotated)
- Committer:
- ackerden
- Date:
- Wed Apr 21 13:48:47 2021 +0000
- Revision:
- 16:f0480e9c5039
- Child:
- 17:621c4212fd4e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ackerden | 16:f0480e9c5039 | 1 | #include "mbed.h" |
ackerden | 16:f0480e9c5039 | 2 | #include "Servo.h" |
ackerden | 16:f0480e9c5039 | 3 | |
ackerden | 16:f0480e9c5039 | 4 | #include "servo_bewegung.h" |
ackerden | 16:f0480e9c5039 | 5 | |
ackerden | 16:f0480e9c5039 | 6 | #define MID 1500 |
ackerden | 16:f0480e9c5039 | 7 | #define MIN 1000 |
ackerden | 16:f0480e9c5039 | 8 | #define MAX 2000 |
ackerden | 16:f0480e9c5039 | 9 | #define STEP 50 |
ackerden | 16:f0480e9c5039 | 10 | //Time delay between steps in milliseconds |
ackerden | 16:f0480e9c5039 | 11 | #define TIME 100 |
ackerden | 16:f0480e9c5039 | 12 | |
ackerden | 16:f0480e9c5039 | 13 | |
ackerden | 16:f0480e9c5039 | 14 | void bewegung(int zeit){ |
ackerden | 16:f0480e9c5039 | 15 | |
ackerden | 16:f0480e9c5039 | 16 | Servo Servo1(PA_0); |
ackerden | 16:f0480e9c5039 | 17 | Servo1.Enable(1500,20000); |
ackerden | 16:f0480e9c5039 | 18 | for(int j=0; j<zeit; j++){ |
ackerden | 16:f0480e9c5039 | 19 | for (int pos = 1000; pos < 2000; pos += 25) { |
ackerden | 16:f0480e9c5039 | 20 | Servo1.SetPosition(pos); |
ackerden | 16:f0480e9c5039 | 21 | wait_ms(STEP); |
ackerden | 16:f0480e9c5039 | 22 | } |
ackerden | 16:f0480e9c5039 | 23 | for (int pos = 2000; pos > 1000; pos -= 25) { |
ackerden | 16:f0480e9c5039 | 24 | Servo1.SetPosition(pos); |
ackerden | 16:f0480e9c5039 | 25 | wait_ms(STEP); |
ackerden | 16:f0480e9c5039 | 26 | } |
ackerden | 16:f0480e9c5039 | 27 | } |
ackerden | 16:f0480e9c5039 | 28 | } |