#include <Servo.h>
Servo Servo1;
int Wartezeit = 400;
int Schritt = 30;
int Richtung = 1; // 1 oder -1
int Winkel = 0;
void setup() {
// put your setup code here, to run once:
pinMode(3, OUTPUT);
Servo1.attach(3);
}
void loop() {
// put your main code here, to run repeatedly:
Servo1.write(Winkel);
Winkel = Winkel + Schritt*Richtung;
if (Winkel > 180) {
Richtung = -Richtung;
Winkel = 180-Schritt;
}
if (Winkel <0) {
Richtung = -Richtung;
Winkel = Schritt;
}
delay(Wartezeit);
}