Introduction: Making a Catapult With Arduino

Hello!

This tutorial will tell you how to make a catapult with an Arduino, it will also play a small sound before you fire it. Here is a video of the final product!

First things first, here is a list with things you will need for the Arduino setup:

  • Arduino (For my project I used the Arduino Yun)
  • 5 Jump wires
  • 1 Pushbutton 6x6mm size
  • 1 Piezo Buzzer
  • 1 Servo
  • 2 Servo hevels
  • 1 Breadboard
  • 1 Micro USB to USB cable
  • A laptop

Next up is the catapult itself, I used parts of an old toy set I found in my house called Mechanix:

  • A wooden plank, the one I used was 30cmx20cm
  • 3 RT-55 (buy here)
  • 4 A-5 (buy here)
  • 2 A-9 (buy here)
  • 3 AB-7 (buy here)
  • 2 BTB-5 (buy here)
  • 2 AB-2 (buy here)
  • 40 mm shaft or longer (buy here)
  • 2 U-clips (buy here)
  • 1 PY - 2 (buy here, optional)
  • Small screw set (buy here) You will need 24 6mm bolts, six 8mm bolts and 30 nuts. I also used six steel washers but this is optional.
  • 2 screws
  • 2 4mm bolts
  • 1 piece of steel/wood (about 5mm in width and 15mm in height)
  • 1 post-it note
  • 1 small piece of steel wire (about 3mm in width and 10cm in height)
  • A piece of carbon fiber (about 1,5cm in width and 20cm in height)
  • 2 pieces of wood made with a lasercutter (download here)
  • Small aluminum block (about 2cmx1cmx1cm)
  • And of course a tool set!

Step 1: Step 1

Start by grabbing the servo and and attaching the AB-2's to it using two bolts and two nuts(6mm). You can also add the servo hevel to the servo now.

Step 2: Step 2

Attach the BTB-5 to the servo so it can stand, using two bolts and two nuts (6mm). (Mine are red, I assume because my Mechanix set is from 1993...)

Step 3: Step 3

Attach the AB-7 to the BTB-5 as seen in the picture, using two bolts and two nuts (6 mm). (Mine are blue instead of the grey they currently sell)

Step 4: Step 4

Time to grab the aluminum block and drill holes in it on the places indicated in the picture with black spots.

Step 5: Step 5

Grab the 40mm shaft and put one of your servo hevels on it (you might need to push a little hard for this, and it probably won't be usable for servos anymore.)

Step 6: Step 6

Put the 40mm shaft with the servo hevel horizontally through the aluminium block, grab your piece of carbon fiber, put it on top of the block and put a small piece of steel on it and drill through it with two small bolts (4mm) on the black spots. This will make sure your carbon fiber won't move. The final picture is the result you should have.

Step 7: Step 7

Grab the three RT-55 (big red plates). Start with putting one down horizontally (make sure its "feet" are on the ground) and attaching the other RT-55 vertically on it, as done in the picture using two bolts and two nuts.

Step 8: Step 8

Put the aluminum block with carbon fiber you made in step 6 through the second hole of the RT-55 (as seen in the first picture) and attach the final RT-55 as seen in the second picture with two bolts and two nuts (6mm). The second picture is what you should end up with.

Step 9: Step 9

Now it's time to grab the steel wire and a nose plier (or something else to bend the wire with) and bend it like its done in the picture, the wire should be about 2,5cm long, with the bended parts being about 5mm long. Finally add it too the servo hevel as seen in the final picture.

Step 10: Step 10

Put the other end of the steel wire through servo hevel, the attach the servo you have made in step 1 - 3 to the RT-55 base, as seen in the picture. Using two bolts and two nuts (6mm). You should put the bolts through the "feet" of the AB-7 as seen in the first picture.

It's important you put the steel wire through the hevel first because you will not have the space to do so once you've attached the two pieces together. It's also important that you make sure the hevels are standing in the same way as in the third picture, or else your catapult might not fire correctly.

Step 11: Step 11

It's time to grab the pieces you've lasercutted, and use the longer bolts and nuts (8mm), use three of each and attach the wooden pieces to the RT-55. Attach the second wooden piece to the other side.

Step 12: Step 12

Grab four A5's and two A9's and attach them too the "feet" of the RT-55 as seen in the picture, using eight bolts and nuts (6mm). do this on both sides. It should be able to stand like in the second picture.

Step 13: Step 13

Grab your piece of wood and the last piece of AB-7 and use the two big screws to put the AB-7 in the center of the piece of wood.

Step 14: Step 14

Attach the A5's to the AB-7 on the piece of wood you have made in step 13, using two bolts and two nuts (6mm). It should look something like the second picture once you're done.

Step 15: Step 15

Grab the second 40mm shaft and put it in the PY - 2 and put a bolt through it (as seen in the second picture). Although the PY - 2 is optional, you could use the 40mm shaft without the PY - 2, you can use the holes in the lasercutted wood to put the 40mm shaft through and put the piece of carbon fiber under it.

Step 16: Step 16

Grab the post-it note

Fold it as seen in picture two (about 2cm in height.) Cut this off

Fold it as seen in picture three (about 2cm in height and width)

Fold it as seen in picture four (about 1,5cm in width)

Fold another piece of 2cm, and cut the excess off. You should end up with something as in picture five.

Finally trim the sides a little bit as seen in picture six

Fold it and stick it to the end of the carbon fiber using tape as seen in picture seven

Step 17: Step 17

You catapult is now complete, and should look something like the pictures above, so it's time to grab your arduino and breadboard.

Step 18: Step 18

Follow the fritzing image above. Once you're done with that it should look something like the second and third picture.

Step 19: Step 19

The last step is to download the Arduino software from here and download my code for the catapult from here.

You will only have to open the code and upload it to your Arduino and you're good to go! If you have uploaded the code to the Arduino and press the pushbutton your catapult should work! I personally found that small marshmallows and peanuts shoot the best!

I hope you had fun!

P.S. I couldn't find a better way to upload my code, since I have to be PRO member to embed a text box.

Woo, I got a PRO membership since this Instructables got featured, below you'll find the code I used. You just have to open the Arduino software and copy paste the code below. After you've done that you have to make a new tab in the Arduino software name this new tab "pitches.h" (shortcut is shift+cmd+N) and copy paste the code at the end of this page. Upload your code to your Arduino and you're good to go!





#include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_C3,NOTE_C3,NOTE_D4,NOTE_D4,NOTE_E5,NOTE_F6,NOTE_G7,NOTE_A7,
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  2, 8, 2, 8, 2, 8, 3, 7, 3, 7, 4, 6, 4, 5,
};

#include 

Servo myservo;  // create servo object to control a servo

void playsound(){
    // iterate over the notes of the melody:
    for (int thisNote = 0; thisNote < 8; thisNote++) {

    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(8, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(8);
  }  
}
void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(3, INPUT_PULLUP);
}

int state = 0;
int oldButtonstate = HIGH;

void loop() {
  if (digitalRead(3) == LOW && oldButtonstate == HIGH)
  {
    oldButtonstate == LOW;
    delay(100);
    if (digitalRead(3) == LOW)
    {
      if (state == 0)
        state = 1;
      else
        state = 0;
    }
  }
  else
  {
    oldButtonstate == HIGH;
  }
  
  if (state == 1)
  {
    playsound(); //plays sound
    myservo.write(5); //start position
    delay(1500); //how long it waits until it moves to the next position
    myservo.write(120); // next position it will move to
    delay(1500);
    myservo.write(5); //next position it will move to
    state = 0;
  }
  else
  {
    myservo.write(120);
  }
}

/*************************************************
 * Public Constants
 *************************************************/

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978