i ended by writting this code, it works correctly but i want to link the linghting of leds with the status of the servo to check if it is borken or succeflly did his last cycle because i am going to put +6h delay between cycles
With this code even the servo is broken the leds continue to light on
#include <Servo.h>
Servo myservo;
int pos = 0;
const int LED1 = 12; // leg for 0 ged
const int LED2 = 4; // leg for 180 deg
void setup() {
myservo.attach(9);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { /* goes from 0 degrees to 180 degrees in steps of 1 degree */
if (pos > 0 && pos < 180) {digitalWrite(LED1, HIGH);} else{
digitalWrite(LED1, LOW);
}
myservo.write(pos);
delay(20);
}
delay(200000);
for (pos = 180; pos >= 0; pos -= 1) { /* goes from 180 degrees to 0 degrees */
if (pos < 180 && pos > 0) {digitalWrite(LED2, HIGH);} else{
digitalWrite(LED2, LOW);
}
myservo.write(pos);
delay(20);
}
delay(200000);
}
Anyone can guide me please ?