i agree with you that the var speed servo probably wasn't the best idea. but it'd be a shame to waste the code if i could easily fix it. i tried adding a second servo to the code last night, and it didnt work.
this was my Finished code when i was done
// Include the servo library
#include <VarSpeedServo.h>
// Create a servo object to control a servo
VarSpeedServo myservo;
VarSpeedServo myservo2;
// this constant won't change:
const int buttonPin = 2; // the pin that the pushbutton is attached to
// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
void setup() {
myservo.attach(9);
myservo2.attach(11);
myservo.slowmove(180, 0);
myservo2.slowmove(0, 180);
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the pushbutton input pin:
int buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
}
else {
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
}
// moves the servo every other button push by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter % 2 == 0) {
myservo.slowmove(0, 180);
myservo2.slowmove(180, 0);
} else {
myservo.slowmove(180, 180);
myservo2.slowmove(180, 180);
}
}
if it doesnt look like this will work for me, i have no problem scrapping it, i just appreciate the help