My program is great ?

#include <Servo.h>

Servo myservo;
int pos = 0;
Servo myservo2;
int pos2 = 0;

int ledPin1 = 13; // choose the pin for the LED1
int ledPin2 = 12; // choose the pin for the LED2
int inputPin1 = 3; // button 1
int inputPin2 = 2; // button 2

void setup() {
pinMode(ledPin1, OUTPUT); // declare LED1 as output
pinMode(ledPin2, OUTPUT); // declare LED2 as output
pinMode(inputPin1, INPUT); // make button 1 an input
pinMode(inputPin2, INPUT); // make button 2 an input
myservo.attach(9);
myservo2.attach(10);
}

void loop(){
if (digitalRead(inputPin1) == LOW)
{
digitalWrite(ledPin1, LOW); // turn LED OFF
}
else if (digitalRead(inputPin1) == HIGH)
{
digitalWrite(ledPin1, HIGH); // turn LED ON
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
else if (digitalRead(inputPin2) == LOW)
{
digitalWrite(ledPin2, LOW); // turn LED OFF
}
else if (digitalRead(inputPin2) == HIGH)
{
digitalWrite(ledPin2, HIGH);
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo2.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo2.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
} // turn LED ON
}
else
{
digitalWrite((ledPin1, ledPin2), LOW);
}
}

no

No because it is not posted correctly. Read the how to use this forum sticky post at the start of this section.

Well it depends what you mean by “great”… if you tried it and it does what you want, then yes it’s “great”!

If it doesn’t compile, or compiles but doesn’t do what you want, then it’s not great and you should then be telling us what messages you get or what it’s doing wrong.

Pointless, non-conforming, post of the week???

 for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees

No it doesn’t.
As far as the body of the “for” loop is concerned, it goes from 0 “degrees” to 179 “degrees”, a small but potentially significant difference.

    digitalWrite((ledPin1, ledPin2), LOW);

I don’t think so.

How to use this forum

if (digitalRead(inputPin1) == LOW)
  {
    digitalWrite(ledPin1, LOW); // turn LED OFF
  }
  else if (digitalRead(inputPin1) == HIGH)

If it isn’t LOW, what else could it possibly be? Tuesday?

PaulS: if (digitalRead(inputPin1) == LOW)   {     digitalWrite(ledPin1, LOW); // turn LED OFF   }   else if (digitalRead(inputPin1) == HIGH)

If it isn't LOW, what else could it possibly be? Tuesday?

It probably won't ever be TUESDAY, but run that code enough in the right environment and it will eventually be LOW. It's a window of opportunity that will be taken advantage of, sooner or later, if that pin changes much. I agree with you, it should be removed. :)