Hauptprogramm
Dependencies: ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini
Servo/servo_bewegung.cpp
- Committer:
- haefeman
- Date:
- 2021-04-22
- Revision:
- 20:f825e91784fe
- Parent:
- 19:9ccd591cb637
- Child:
- 22:f71d32309307
File content as of revision 20:f825e91784fe:
#include "mbed.h" #include "Servo.h" #include "servo_bewegung.h" #define MID 1500 #define MIN 1000 #define MAX 2000 #define STEP 50 //Time delay between steps in milliseconds #define TIME 100 void bewegung(){ Servo servo1(PA_0); servo1.Enable(1000,20000); //Servo Bewegung for (int pos = 1000; pos > 800; pos -= 25) { servo1.SetPosition(pos); thread_sleep_for(STEP); } for(int j=0; j<2; j++){ for (int pos = 800; pos < 1200; pos += 25) { servo1.SetPosition(pos); thread_sleep_for(STEP); } for (int pos = 1200; pos > 800; pos -= 25) { servo1.SetPosition(pos); thread_sleep_for(STEP); } } for (int pos = 800; pos < 1000; pos += 25) { servo1.SetPosition(pos); thread_sleep_for(STEP); } servo1.Disable(); }