Kitty Candy Cannon

Kitty Candy Cannon

thingiverse

Kitty candy cannon ==================== An introduction --------------------- First off, I'm a novice at both CAD and Arduino. This was a project for me to learn a little of both. It's probably faster (definately cheaper) to just throw candy to your cat. As you can see in the videos Harry is as excited as me to finally see this thing in working order. Ungrateful cat... ### The cannon The cannon has a magazine holding 9 candies. When the button is pressed a servo pushes the magazine forward, dropping a candy down to the trigger. Then it moves to a random horizontal and vertical position. When in position the motor rotates the axle pushing the trigger back until it fires. After firing it goes back to it's original position. ### Printed parts All stl:s are placed in the way they need to be printed for strength, detail and so on. I've tried to minimize the need for supports but some of the parts have to have them, and a few of the taller parts need a brim to stick to the build plate. The Reloader base has supports included in the stl so you'll only have to add a brim for that part. Just break them off when you're finished printing. Assembly ==================== ### Electronics box ![Electronics](https://cdn.thingiverse.com/renders/23/7f/4b/73/ec/2be246fd9a4cc144218cab9be5b56064_preview_featured.jpg) Glue the servo holder and the axle in place. When the glue is dry, screw the servo in place. The indent with the slots are for holding the trigger button. ### Base ![Base](https://cdn.thingiverse.com/renders/25/db/41/b4/64/854d1b0477393b5b9e4deca143863b25_preview_featured.jpg) Glue the servo holders and rotator in place. When the glue has dried you can screw the larger servo in place. When you put this on the axle on the electronics box you can add the wire going from the box's servo to the rotator. ### Cannon ![Cannon](https://cdn.thingiverse.com/renders/7d/a0/21/6f/0d/1130cbc1f504d5921b1d252fd2b57860_preview_featured.jpg) Attach the motor axle to the motor and slide it in place. Put the spring on the firing pin guide and add shims if necessary. Insert the guide in the firing pin, compress it and push it in place. ![Cannon](https://cdn.thingiverse.com/renders/d9/35/44/01/06/13b28cec7aeb6e4e22c9f9892d0b217c_preview_featured.jpg) Hold the trigger axle in place, add some glue and push the axle studs in. Also glue the lifter anchor in place. You'll need a piece of at least 1,5mm thick wire to attach the lifter servo to the anchor on the cannon. ### Reloader ![Reloader](https://cdn.thingiverse.com/renders/c8/33/72/06/a2/82f04b42bdefb00493d980d804b27d2b_preview_featured.jpg) Slide the magazine in place and attach a rubber band from the magazine to the reloader base. Push the magazine catch in place. The catch will keep the magazine in position when the servo moves back to reload. Insert the magazine pusher in the servo attachment and screw that onto your servo. Then screw the servo in place Lego wiring --------------------- ![Lego wiring](https://cdn.thingiverse.com/renders/be/8a/2c/05/6d/3fde15cfb7a49c1ec28b5797ef29ddfa_preview_featured.jpg) - *GND: Ground wire – 0V* - *C1: Control 1 - 9V when in forward* - *C2: Control 2 – 9V when in reverse* - *9V: Power wire – 9V always* If you've got an extension wire, just cut it in half and solder breadboard connectors to both. You'll need one for connecting the battery box, and one for the motor. For the battery box you use the 9V (red) and GND (blue) wires, so insulate both control wires (green). For the motor you'll use the control wires so insulate the GND (blue) and 9V (red) wires. ### Arduino wiring ![Arduino wiring](https://cdn.thingiverse.com/renders/03/b7/95/f1/3e/1b6c1d740eace03782a097c8a60bcb2d_preview_featured.jpg) I used a motor shield so the motor goes to the shield's A1 and A2 connectors. The battery box goes both to the motor shields power input and the power rail on the breadboard to feed the servos. Make sure the motor shield jumper is set to use external power. The 4xAA battery box goes in the arduino Code --------------------- The only thing you'll have to modify in the code is the positions of the servos. All positions are set at the top of KittyCandyCannon.ino. The positions will probably need a little triming in. ```C #include <Button.h> #include <Servo.h> unsigned int buttonPin = 13; Button startStop(buttonPin); unsigned int motorPwm = 3; unsigned int motorDirection = 2; // Servo settings Servo vertical; unsigned int verticalPrevious; unsigned int verticalServoPin = 6; unsigned int verticalMin = 10; unsigned int verticalMax = 35; Servo horizontal; unsigned int horizontalPrevious; unsigned int horizontalServoPin = 5; unsigned int horizontalReset = 90; unsigned int horizontalMin = 10; unsigned int horizontalMax = 90; Servo reload; unsigned int reloadServoPin = 9; unsigned int reloadStart = 47; unsigned int reloadEnd = 5; void setup() { startStop.begin(); pinMode(motorPwm, OUTPUT); pinMode(motorDirection, OUTPUT); // Attach and move servos to starting position horizontalPrevious = horizontalReset; verticalPrevious = verticalMin; vertical.attach(verticalServoPin); moveServo(vertical, verticalMin, verticalMin, 15); horizontal.attach(horizontalServoPin); moveServo(horizontal, horizontalPrevious, horizontalPrevious, 15); reload.attach(reloadServoPin); moveServo(reload, reloadStart, reloadStart, 15); } void loop() { if (startStop.pressed()) { repositionAndFire(); } } void repositionAndFire() { reloadCannon(); verticalPrevious = moveServoRandom(vertical, verticalMin, verticalMax, verticalPrevious, 15); horizontalPrevious = moveServoRandom(horizontal, horizontalMin, horizontalMax, horizontalPrevious, 5); fireCannon(); resetPosition(); } void resetPosition() { moveServo(vertical, verticalPrevious, verticalMin, 15); moveServo(horizontal, horizontalPrevious, horizontalReset, 15); } void reloadCannon() { moveServo(reload, reloadStart, reloadEnd, 5); delay(1500); moveServo(reload, reloadEnd, reloadStart, 10); } void moveServo(Servo servo, int oldPosition, int newPosition, int speed) { moveServoWithDelay(servo, oldPosition, newPosition, speed); } int moveServoRandom(Servo servo, int start, int end, int oldPosition, int speed) { unsigned int newPosition = random(start, end); moveServoWithDelay(servo, oldPosition, newPosition, speed); delay(1000); return newPosition; } void moveServoWithDelay(Servo servo, int oldPosition, int newPosition, int speed) { newPosition = mapPosition(newPosition); oldPosition = mapPosition(oldPosition); if (oldPosition <= newPosition) { for (; oldPosition <= newPosition; oldPosition++) { servo.write(oldPosition); delay(speed); } } else { for (; oldPosition >= newPosition; oldPosition--) { servo.write(oldPosition); delay(speed); } } } void fireCannon() { // Run motor to pull spring back and fire digitalWrite(motorDirection, LOW); analogWrite(motorPwm, 255); // Approximately one revolution of the trigger wheel delay(4100); analogWrite(motorPwm, 0); } int mapPosition(int position) { return map(position, 0, 180, 0, 254); } ``` Hardware --------------------- What you'll need other than the printed parts are: - Arduino + wires - Motor/servo shield - Breadboard - Lego 8881 battery box - Lego 88003 L-motor - Lego 8886 extension wire (for not cutting the original wire) - 2 x micro servos (800g) - 1 x standard servo (>4kg) - 4 x AA battery holder - Wire for servos - Rubber band (for the magazine) - 2 x 4mm nuts & bolts (for the cannon hinge) - 10 x AA batteries - Glue https://www.youtube.com/watch?v=I9LZMGxK5ME https://www.youtube.com/watch?v=QlNiYxCDKL8

Download Model from thingiverse

With this file you will be able to print Kitty Candy Cannon with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Kitty Candy Cannon.