// Wichtig ist zunächst die Ermittlung des zulässigen Winkelbereichs</code>
#include
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer (10k)
int ldrpin = 1; // LDR-Pin mit 10k Widerstand(GND)-(LDR/A1) LDR:(5V-A1)
int val, light; // variable to read the value from the analog pin
void setup()
{
Serial.begin(9600);
myservo.attach(4); // attaches the servo on pin 4 to the servo object
}
void loop()
{
// scale it to use it with the servo (value between 75 and 115 (0-180))
// sets the servo position according to the scaled value
// Serial.print("value=");
// Serial.print(light);
// Serial.println();
delay(100);
for (int i=85; i <= 110; i=i+7)
{
myservo.write(i);
delay(500);
}
delay(500); // waits for the servo to get there
}
Ähnliche Beiträge