Introduction: Cat Ball Shooter
Materials needed
1 x RFID Sensor/ remote
1 x Arduino uno
2 x DC motors
1 x 180 servo
1 x 360 servo
multiple wires
Box/container to build project
pipe to feed ball through
Step 1: Create the Circuit to Power the Motors and Remote
Building the circuit
build the circuit above and connect to the same pins to use the exact same code
Step 2: Create Base for the Two Motors
you will need to use the foam board to cut 4, 5 inch by 2 inch rectangles for the sides. then cut out 2, 5 by 5 inch squares to use as the top and bottom. next the motors will need a place to sit on so cut 2 holes that are 23mm in diameter and 39mm apart from each other to give room for the ball to be shot. then make a spot or a couple holes on the bottom square to allow the wires from the motors to connect into the circuit.
Step 3: Add the Servo to the Bottom of the Motors
carefully glue the 180 or 360 servo on to the bottom (in the middle) of the square. we are doing this so we can change the direction manually with the remote or randomly so the ball shoots in different directions
Step 4: Cut Holes in the Large Container
take the large container and cut a hole in the front and back, it does not have to be exact but in the front it should we pretty big as seen in the picture to allow the ball to be shot in different directions with the servo moving. and the back of the container cut a smaller hole to allow the wires to come out and to place the circuit parts in or the change the circuit if needed. in the front glue the servo to the lid of one of the containers and then onto the base of the container for support, see the second picture for reference
Step 5: The Pipe
make or buy a pvc pipe that is 1 foot long, preferably with a curve to let the ball roll in then cut a peice 1.5" in to let the ball come in
Step 6: The Hopper
cut out 4 equal trapezoids, can be of choice but mine were 5" tall and slanted a bit when put on to the pipe, then the piece of foam board at the bottom cut a hole big enough for a ping pong ball to go through. next glue them together forming a hopping for all the balls to sit in. later we will glue this to the top of the pipe where the hole is cut
Step 7: Placing the Hopper, Pipe and Motors
you will want to place the pipe inside the container sitting just on the edge of the white box made for the motors so that the ball will come out and be pushed by the wheels. you can now glue on the hopper to the top of the pipe
Step 8: The Final Servo
this servo is glued on to the bottom of the hopper/ where the pipe i cut to just have it stick out enough to where the ping balls will not fall through until the button is clicked and the servo moves
Step 9: Add Code to Test the Working Parts
//Cat fixer
//import libraries to use commands throughout the code, for example, declaring pins as servos and setting up the IR remote #include #include
//setting up variables to set speeds for the DC motors int onspeed = 255; int lowspeed = 100; int offspeed = 0;
//setting up the infared reciever pin and the two motor pins int IR_Recv = 2; int motor1 = 10; int motor2 = 11;
//declaring the variables as servos so the program knows it is a servo to use specific commands Servo flap; Servo angle;
//declaring IR pin to recieve inputs from remotes //gets the results from the remote IRrecv irrecv(IR_Recv); decode_results results;
void setup() {
Serial.begin(9600); //starts serial communication irrecv.enableIRIn(); // Starts the receiver
flap.attach(7); //attaches the servo flap to pin 7 so we can use it later in the program angle.attach(4); //attaches the servo angle to pin 4 so we can use it later in the program pinMode(motor1, OUTPUT); //set motor1 to an output so we can send speeds to in when button is pushed pinMode(motor2, OUTPUT); //set motor2 to an output so we can send speeds to in when button is pushed
}
void loop() {
flap.write(0); //set the servo controlling the ball feeder to 0 degrees to not let any balls through
if (irrecv.decode(&results)){ long int decCode = results.value; Serial.println(decCode); irrecv.resume();
switch(results.value) {
case 0xFFA25D: //power analogWrite(motor1,onspeed); analogWrite(motor2,onspeed); delay(7000); flap.write(90); delay(500); flap.write(0); delay(2000); analogWrite(motor1,offspeed); analogWrite(motor2,offspeed); break;
case 0xFFE01F: //EQ
analogWrite(motor1,onspeed); analogWrite(motor2,lowspeed); delay(7000); flap.write(90); delay(500); flap.write(0); delay(2000); analogWrite(motor1,offspeed); analogWrite(motor2,offspeed);
break;
case 0xFF629D: //mode
analogWrite(motor1,lowspeed); analogWrite(motor2,onspeed); delay(7000); flap.write(90); delay(500); flap.write(0); delay(2000); analogWrite(motor1,offspeed); analogWrite(motor2,offspeed);
break;
case 0xFF30CF: //settng 1, 90 degrees
angle.write(30);
break;
case 0xFF18E7: //setting 2, 0 degrees
angle.write(90);
break;
case 0xFF7A85: //setting 3, 180 degrees
angle.write(150);
break;
} } }