Thanks for the help. I'm trying to learn this, but it is a lot to take in with no experience. The buttons have no effect and the servos jitter continuously. New code below.
#include <Servo.h>
const int abuttonPin = 4;
const int rbuttonPin = 2;
const byte atservoPin = 3;
const byte amservoPin = 5;
const byte abservoPin = 6;
const byte rtservoPin = 9;
const byte rmservoPin = 10;
const byte rbservoPin = 11;
Servo atservo;
Servo amservo;
Servo abservo;
Servo rtservo;
Servo rmservo;
Servo rbservo;
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int buttonState2 = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
int lastButtonState2 = 0; // previous state of the button
void setup()
{
pinMode(abuttonPin, INPUT_PULLUP);
pinMode(rbuttonPin, INPUT_PULLUP);
atservo.write(0);
amservo.write(0);
abservo.write(0);
rtservo.write(0);
rmservo.write(0);
rbservo.write(0);
atservo.attach(3);
amservo.attach(5);
abservo.attach(6);
rtservo.attach(9);
rmservo.attach(10);
rbservo.attach(11);
Serial.begin(9600);
}
void loop()
{
// read the pushbutton input pin:
buttonState = digitalRead(abuttonPin);
buttonState2 = digitalRead(rbuttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState)
{
if (buttonState == LOW)
{
// if the current state is LOW then the button
// went from off to on:
buttonPushCounter++;
if(buttonPushCounter == 1)
{
atservo.write(0);
amservo.write(0);
abservo.write(0);
}
if(buttonPushCounter == 2)
{
rtservo.write(90);
rmservo.write(90);
rbservo.write(90);
buttonPushCounter = 0;
}
}
delay(500);
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
// if the state has changed, increment the counter
if (buttonState2 == LOW)
{
// if the current state is LOW then the button
// went from off to on:
buttonPushCounter++;
if(buttonPushCounter == 1)
{
rtservo.write(0);
rmservo.write(0);
rbservo.write(0);
}
if(buttonPushCounter == 2)
{
rtservo.write(45);
rmservo.write(15);
rbservo.write(75);
delay(4000);
rtservo.write(0);
rmservo.write(45);
rbservo.write(15);
delay(6000);
rtservo.write(75);
rmservo.write(0);
rbservo.write(45);
delay(2000);
rtservo.write(15);
rmservo.write(75);
rbservo.write(0);
delay(7000);
rtservo.write(0);
rmservo.write(0);
rbservo.write(0);
delay(5000);
buttonPushCounter = 0;
}
}
delay(15);
lastButtonState2 = buttonState2;
}
}