Autonomous tennis ball shooter

My parents have requested a autonomous tennis ball shooting machine for our dogs when they’r home alone. My plan for it was to use the RobotOpen shield (RobotOpen :: Hardware :: RobotOpen Control Shield for Arduino) and a FRC control system. It needs to detect a ball at the top of a ramp, and after the ball trips a limit switch at the top (http://www.vexrobotics.com/276-2174.html) spin up the motors for a preset amount of time (the time it takes the ball to roll down and get launched by the wheels, probably 3-5 seconds), then shut down the motors and await the next time the limit switch trips.

This is the tank drive RobotOpen program

 #include <SPI.h>
#include <Ethernet.h>
#include <RobotOpen.h>


/* I/O Setup */
USBJoystick usb1('0');  // Assign the logitech USBJoystick object to bundle 0


void setup()
{
  /* Initiate comms */
  RobotOpen.begin();
}


/* This is your primary robot loop - all of your code
 * should live here that allows the robot to operate
 */
void enabled() {
  // Constantly update PWM values with joystick values
  RobotOpen.setPWM(SIDECAR_PWM1, usb1.makePWM(ANALOG_LEFTY, INVERT));
  RobotOpen.setPWM(SIDECAR_PWM2, usb1.makePWM(ANALOG_RIGHTY, NORMAL));
}


/* This is called while the robot is disabled
 * You must make sure to set all of your outputs
 * to safe/disable values here
 */
void disabled() {
  // PWMs are automatically disabled
}


/* This loop ALWAYS runs - only place code here that can run during a disabled state
 * This is also a good spot to put driver station publish code
 * You can use either publishAnalog, publishDigital, publishByte, publishShort, or publishLong
 * Specify a bundle ID with a single character (a-z, A-Z, 0-9) - Just make sure not to use the same twice!
 */
void timedtasks() {
  RobotOpen.publishAnalog(ANALOG0, 'A');   // Bundle A
  RobotOpen.publishAnalog(ANALOG1, 'B');   // Bundle B
  RobotOpen.publishAnalog(ANALOG2, 'C');   // Bundle C
  RobotOpen.publishAnalog(ANALOG3, 'D');   // Bundle D
  RobotOpen.publishAnalog(ANALOG4, 'E');   // Bundle E
  RobotOpen.publishAnalog(ANALOG5, 'F');   // Bundle F
}


/* This is the main program loop that keeps comms operational
 * There's no need to touch anything here!!!
 */
void loop() {
  RobotOpen.pollDS();
  if (RobotOpen.enabled())
    enabled();
  else
    disabled();
  timedtasks();
  RobotOpen.outgoingDS();
}

How can this be modified to allow for all the necessary tasks of a autonomous tennis ball shooter???

There are a lot of tennis ball shooting machinese.

I suggest you get one, and then figure out how to get the ardunio to turn it on , and off, rather than try to "re-invent the wheel", but doing the whole thing yourself.

There was a dog ball launcher featured in Make:31...

Seeing as you have dogs, plural, can't you just teach them to throw the ball for each other?

I think a swimming pool would be easier and more fun for you as well ]:D http://www.youtube.com/watch?v=St_4vYCPax4

Ok, so if I ditch the RobotOpen system and just use the arduino, can someone help me?? the program needs to wait for a signal from the VEX limit switch, and when the signal is received spin up the motors (Victor 888 for speed control) for 5 seconds, then shut off the motors and wait for the switch to trip again

The code shouldn’t be that hard, you just have to remember to wire the limit switch correctly. http://arduino.cc/en/tutorial/button

#include <Servo.h> // We will use the servo library, because I have heard it works better with motor controllers like the Victor/Jaguar/Talon
Servo controller;

const int limitSwitch=3; // Digital pin for limit switch
const int motorPin=10; // Make sure this is a PWM pin

const int motorOnValue=180; // The value that will turn the motor on
const int motorOffValue=90; // The value that will turn the motor off

// Stuff for debounce:
int current;
int buttonState;
int lastButtonState=LOW;
long lastDebounceTime=0;
long debounceDelay=500; // Milliseconds

void setup(){
	controller.attach(motorPin);
}

void loop(){
	current=digitalRead(limitSwitch);
	if(current!=lastButtonState){
		lastDebounceTime=millis();
	}
	
	if((millis()-lastDebounceTime)>debounceDelay){
		if(current!=buttonState){
			buttonState=current;
			if(buttonState==HIGH){
				controller.write(motorOnValue); // Turn the motor on
			}else{
				controller.write(motorOffValue); // Turn the motor off
			}
		}
	}
}

cr0sh's suggestion is worth repeating: http://blog.makezine.com/projects/make-31/fetch-o-matic/. Just one limit switch needed with this design; no microcontroller/etc.

I have working code now, now the question is can I have a display with 2 buttons for speed adjustments?? Its going to need to run maybe 25-50% indoors and full power outside. This possible??