#include <Servo.h>
#define SERVO_PIN 3 //define as a constant the SERVO PIN
Servo Servo1;
int Zeit = 800;
int Winkel =0;
int Schritt = 30;
void setup() {
pinMode(SERVO_PIN, OUTPUT); //setup the pin as output
Servo1.attach(SERVO_PIN);
Serial.begin(9600);
}
void loop() {
Servo1.write(Winkel);
delay(Zeit);
Serial.println(Winkel);
if (Winkel >= 180) {
Schritt = -Schritt;
}
if (Winkel < 0) {
Schritt = -Schritt;
}
Winkel = Winkel + Schritt;
}