it is so much easier to read code when properly indented
#include <Servo.h>
Servo myservo;
int pos = 0;
const int LED1 = 12; // leg for 0 ged
const int LED2 = 4; // leg for 180 deg
int val = 0; // variable for reading the pin status
void setup() {
myservo.attach(9);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop() {
/* goes from 0 degrees to 180 degrees in steps of 1 degree */
for (pos = 0; pos <= 180; pos += 1) {
if (pos > 0 && pos < 180) {
digitalWrite(LED1, HIGH);
}
else {
digitalWrite(LED1, LOW);
}
myservo.write(pos);
delay(20);
}
delay(200000);
/* goes from 180 degrees to 0 degrees */
for (pos = 180; pos >= 0; pos -= 1) {
if (pos < 180 && pos > 0) {
digitalWrite(LED2, HIGH);
}
else {
digitalWrite(LED2, LOW);
}
myservo.write(pos);
delay(20);
}
delay(200000);
}