Button Servos

My first ever Sketch. I was using 1 button to test this and changing the input from 2 to 3. Either or servo moved which ever input I put it in. Still testing with one button I put another pull down resister in the other button Pin input.Now the input is tied to its servo.Now I can change the Button inputs for relays and control as many servos independently as I want. So the sketch was OK all along.

#include <Servo.h>

Servo myservo; // create servo object to control a servo
Servo myservo1; // a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position
int pos1=0;
int buttonPin = 2; // The button will be on Pin2
int buttonPin1 =3;
void setup()
{ myservo1. attach(8);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode(pos, OUTPUT);
pinMode(pos1,OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin1,INPUT);
digitalWrite(buttonPin1,LOW);
digitalWrite (buttonPin, LOW);
}

void loop()
{
{
if (digitalRead(buttonPin) == LOW)

for(pos = 0; pos < 30; pos += 30) // goes from 0 degrees to 30 degrees
{ // in steps of degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’

}
if (digitalRead(buttonPin) == HIGH)

for(pos = 30; pos>=30; pos-=30) // goes from 30 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay (4000); // waits 4000ms and returns to home position.
}
}

{

if (digitalRead(buttonPin1) == LOW)

for(pos1 = 0; pos1 < 30; pos1 += 30) // goes from 0 degrees to 30 degrees
{ // in steps of degree
myservo1.write(pos1); // tell servo to go to position in variable ‘pos’

}
if (digitalRead(buttonPin1) == HIGH)

for(pos1 = 30; pos1>=30; pos1-=30) // goes from 30 degrees to 0 degrees
{
myservo1.write(pos1); // tell servo to go to position in variable ‘pos’
delay (4000); // waits 4000ms and returns to home position.
}
}
}

barriebetty:
So the sketch was OK all along.

Does that mean you have no questions?
Or is this a follow-up to another Thread elsewhere in the Forum - if so why start a new Thread?

When posting code please use code tags (the button like a scroll with <>) so the code

looks like this and has no smileys

…R