#include <Servo.h>
Servo Servo1;
int Schritt = 30;
int Winkel = 0;
int Richtung = 1; // 1 oder -1
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);
if (Winkel > 180) {
Richtung = -Richtung;
Winkel = 180-Schritt;
}
else if (Winkel <0) {
Richtung = -Richtung;
Winkel = Schritt;
}
Winkel = Winkel + Schritt*Richtung;
delay(500);
}