Nathan King
Published © GPL3+

Automatic Catapult for Throwing Pet Food, Balls, and More!

Automatic catapult for throwing pet food (dog, cat, chicken, etc.), balls and more!

IntermediateFull instructions providedOver 1 day12,951
Automatic Catapult for Throwing Pet Food, Balls, and More!

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Servo Module (Generic)
×3
Micro Limit Switch
OpenBuilds Micro Limit Switch
×1
Resistor 10k ohm
Resistor 10k ohm
×1
AA Batteries
AA Batteries
×10
Slide Switch
Slide Switch
×2
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Automatic catapult - Fritzing

Code

Automatic catapult - Arduino code

Arduino
/*
 *  Automatic pet food flinger by Nathan King June 2018
 */

#include <Servo.h>

int FoodDeliveryReleasePosition = 115;
int FoodDeliveryHoldPosition = 0;
int TriggerReleasePosition = 90;
int TriggerHoldPosition = 0;

int limit_switch = 3;
int switch_state = 0;

Servo fooddelivery; //  create servo object to control the food delivery arm
Servo trigger;     // create servo object to control the trigger
Servo rotater;     // create servo object to control the rotator

void setup() {
  rotater.attach(2);            // attaches the rotator servo 
  trigger.attach(4);            // attaches the trigger servo
  fooddelivery.attach(5);       // attaches the food delivery servo
  pinMode(limit_switch, INPUT);
  Serial.begin(9600);
}

void loop() {
  rotater.write(89);                // stops Rotator servo from moving - unnecesary if you have a good servo ;)
  delay(500);

// Start positions
  fooddelivery.write(FoodDeliveryHoldPosition);
  delay(1000);
  trigger.write(TriggerHoldPosition);
  delay(1000);
  trigger.write(TriggerReleasePosition);
  delay(1000);

// limit switch loop to stop the Rotator servo
   switch_state = digitalRead(limit_switch);
   Serial.println(switch_state);
    while (switch_state == HIGH) {
      switch_state = digitalRead(limit_switch);
      Serial.println("Switch is off");
      rotater.write(75);                // starts Rotator clockwise at xx speed (0-255)
    }
   Serial.println("Switch is on");
   rotater.write(89);                // stops Rotator servo

// Holds the catapult arm on the trigger and resets the Rotator to the starting position
  trigger.write(TriggerHoldPosition);
  delay(1000);
  rotater.write(110);
  delay(4500);
  rotater.write(89);

  delay(2000);
  
//  Food delivery to catapult
  fooddelivery.write(FoodDeliveryReleasePosition);
  delay(500);
  fooddelivery.write(FoodDeliveryReleasePosition);  // wait for food to fall
  delay(1000);
  fooddelivery.write(FoodDeliveryHoldPosition);
  delay(150);

// This is to add a delay between the food delivery and the trigger releasing
  rotater.write(89);                   
  delay(1000);                       

// Release catapult!!  
  trigger.write(TriggerReleasePosition);
  delay(3000);                        // delay for the pet to find the food - edit this to change how quickly the food is delivered :)
}

Credits

Nathan King

Nathan King

2 projects • 7 followers
Inventor, maker, hacker, etc

Comments