Hauptprogramm

Dependencies:   ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini

Servo/servo_bewegung.cpp

Committer:
ackerden
Date:
2021-04-23
Revision:
22:f71d32309307
Parent:
20:f825e91784fe
Child:
26:caa4fab7023e

File content as of revision 22:f71d32309307:

#include "mbed.h"
#include "Servo.h"

#include "servo_bewegung.h"

#define MID         1500
#define MIN         1000
#define MAX         2000
#define MIT          800
#define STEP          25
//Time delay between steps in milliseconds
#define TIME         100


void bewegung(){
    Servo servo1(PA_0);
    servo1.Enable(MIN,MAX);
    
    //Servo Bewegung
    for (int pos = MIN; pos > MIT; pos -= STEP) {
        servo1.SetPosition(pos);
        thread_sleep_for(TIME);
    }
    for(int j=0; j<2; j++){
        for (int pos = MIT; pos < MID; pos += STEP) {
            servo1.SetPosition(pos);
            thread_sleep_for(TIME);
        }
        for (int pos = MID; pos > MIT; pos -= STEP) {
            servo1.SetPosition(pos);
            thread_sleep_for(TIME);
        }
    }
    for (int pos = MIT; pos < MIN; pos += STEP) {
        servo1.SetPosition(pos);
        thread_sleep_for(TIME);
    }
    servo1.Disable();
}