Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
Servo/servo_bewegung.cpp@22:f71d32309307, 2021-04-23 (annotated)
- Committer:
- ackerden
- Date:
- Fri Apr 23 16:00:39 2021 +0000
- Revision:
- 22:f71d32309307
- Parent:
- 20:f825e91784fe
- Child:
- 26:caa4fab7023e
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 | 22:f71d32309307 | 9 | #define MIT 800 |
ackerden | 22:f71d32309307 | 10 | #define STEP 25 |
ackerden | 16:f0480e9c5039 | 11 | //Time delay between steps in milliseconds |
ackerden | 16:f0480e9c5039 | 12 | #define TIME 100 |
ackerden | 16:f0480e9c5039 | 13 | |
ackerden | 16:f0480e9c5039 | 14 | |
haefeman | 20:f825e91784fe | 15 | void bewegung(){ |
haefeman | 20:f825e91784fe | 16 | Servo servo1(PA_0); |
ackerden | 22:f71d32309307 | 17 | servo1.Enable(MIN,MAX); |
haefeman | 20:f825e91784fe | 18 | |
haefeman | 20:f825e91784fe | 19 | //Servo Bewegung |
ackerden | 22:f71d32309307 | 20 | for (int pos = MIN; pos > MIT; pos -= STEP) { |
haefeman | 20:f825e91784fe | 21 | servo1.SetPosition(pos); |
ackerden | 22:f71d32309307 | 22 | thread_sleep_for(TIME); |
haefeman | 20:f825e91784fe | 23 | } |
haefeman | 20:f825e91784fe | 24 | for(int j=0; j<2; j++){ |
ackerden | 22:f71d32309307 | 25 | for (int pos = MIT; pos < MID; pos += STEP) { |
haefeman | 20:f825e91784fe | 26 | servo1.SetPosition(pos); |
ackerden | 22:f71d32309307 | 27 | thread_sleep_for(TIME); |
haefeman | 20:f825e91784fe | 28 | } |
ackerden | 22:f71d32309307 | 29 | for (int pos = MID; pos > MIT; pos -= STEP) { |
haefeman | 20:f825e91784fe | 30 | servo1.SetPosition(pos); |
ackerden | 22:f71d32309307 | 31 | thread_sleep_for(TIME); |
haefeman | 20:f825e91784fe | 32 | } |
haefeman | 20:f825e91784fe | 33 | } |
ackerden | 22:f71d32309307 | 34 | for (int pos = MIT; pos < MIN; pos += STEP) { |
haefeman | 20:f825e91784fe | 35 | servo1.SetPosition(pos); |
ackerden | 22:f71d32309307 | 36 | thread_sleep_for(TIME); |
haefeman | 20:f825e91784fe | 37 | } |
haefeman | 20:f825e91784fe | 38 | servo1.Disable(); |
ackerden | 16:f0480e9c5039 | 39 | } |