Introduction: If This Then That - Nerf Gun Turret
Hello all,
In this instructable I will tell you how I made a bluetooth controlled nerf gun. I did this for a project at my school called "If This Than That" ("ITTT"). Note that this is a school project and that I did not manage to fix all errors and bugs for this is one of the few times I worked with Arduino's.
In this project I decided to build a bluetooth controlled Nerf gun turret. I did recreate a big part of this tutorial, but I also altered some things to save time and money and because I wanted to explore this project on my own.
Step 1: What Do We Need?
First of all, you will need a nerf gun. I chose the Nerf N-Strike vulcan because it is easy to modify and has a built-in motor for shooting, which we will discuss later.
The things we need:
Electronics:
- 1x Arduino Uno
- 1x 9v battery (we use the battery pack included in the nerf gun)
- 1x 1k resistor
- 1x TIP 122 resistor
- 1x Servo (!note: The Nerf gun is quite heavy and requires a servo with enough torque. I used the Hitec hs805bb)
- 1x HC-05/ HC-06 Bluetooth module
- 1x Nerf N-Strike Vulcan
- Any android smartphone running android 4.4 or higher.
- Breadboard, wires, prototype boards.
Tools:
- Soldering Iron
- Hot glue gun
- Dremel
- Electronic screwdriver
- Jig saw
- Small screwdriver
Other items used:
- Multiplex ( 100cm x 100cm )
- Wood glue
- Screws
- Double-sided tape
- sandpaper
Step 2: Modifying the Nerf Gun
Two small modifications:
In order to connect the nerf gun to the Arduino and later on to the base of the turret we will need to make a few adjustments. First, we need to open up the gun. You can do this by pulling of the orange handle on the side and then removing the handgrip and screws from the body.
After you have opened up the gun you will see a motor beside the trigger of the gun. All we need to do here is solder on a wire to the + side and - side of the motor. after this is done you need to drill two small holes through the body of the nerf gun for the wires to come out.
after this is done you can close the gun again and put all the screws back in.
The next step is to add the piece of wood of 20 by 7 underneath the nerf gun and use screws to connect it to the gun, like shown in the picture. We will come back to this later.
Step 3: Building the Wooden Base
Change of plan:
My original plan was to follow the instructable mentioned before and make a nerf gun that is able to move on a tilt en rotation axis (x and y) but I figured that the tilt-axis was too much of a hassle without it adding too much to the finished project.
Only I did this after I had sawn al the pieces of wood, so I could not rework the design and that left me with two holes in the body. So I decided to figure out another way to use the same wood I already had in a different way to make it work.
For the most part I did follow the building instructions in the instructable mentioned, but I had to stray from it because I did not implement tilt-axis and I also lacked the axial layer they used.
Getting some work done:
Cut a hole of around the size of the servo in a 20cm x 20cm plate and attached the servo to it with screws and and then I glued the plate with the circular hole in it over the servo as a means of support (see pictures).
Then I drilled a hole through the middle of the base of the turret where I could put a screw through it and connect it to the servo. I also added two screws through the bottom of the base of the turret, put the screws through it pointing upwards (see the photo) This will be used to connect the turret and the gun later.
Step 4: Putting the Gun Together
Putting the gun together is the easy part.
Step 5: Wiring
The turret consists of two separate parts: The servo for movement and the motor of the gun. these parts are are both connected by the bluetooth module. The scheme included shows which wire goes where.
The servo:
Attaching the servo to the Arduino is an easy task, it only requires three wires, one from the power of the servo to the 5v, one from the ground of the servo to the ground on the Arduino and one from the control to digital pin 9 on the Arduino.
The gun motor:
The gun motor on the other hand is a harder task. Since the Arduino doesn't give enough power to power the motor, it requires an external power source. In this instructable we use the nerf gun's own battery.
You cannot just put the batteries straight on to the circuit, so we need to use a transistor as a conductor between the Existing Arduino circuit and the wires we are going to add to the motor.
You might want to check out if you have got the circuit of the nerf gun motor right. If this is the case you can first test the circuit with a led and a 3v battery. If it works, all you have to do is to replace the 3v with the nerf battery pack and the led with the cables shown in the scheme above.
Step 6: Coding
The code I used is actually very simple. I combined the built-in "Blink" (which is used to make leds "blink") and combined it with the "sweep" of the servo. Then all I had to do is replace the fixed positions of the motor with a variable that is read from the bluetooth receiver.
*note because of time shortage I did not incorporate shooting from the bluetooth app.
The code:
//Code for Nerf gun Turret
Servo rotionServo; // create servo object to control a servo
int ServoPos = 0; // variable to store the servo position int pin = 8;
int bluetoothTx = 11; // bluetooth tx to 10 pin int bluetoothRx = 10; // bluetooth rx to 11 pin
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); void setup() { rotationServo.attach(9); // attaches the servo on pin 9 to the servo object pinMode(pin, OUTPUT);
//Setup usb serial connection to computer Serial.begin(9600);
//Setup Bluetooth serial connection to android bluetooth.begin(9600);}
void loop() {
digitalWrite(pin, HIGH); //turns motor on and makes the nerf gun shoot delay(1000); //wait 1 second. digitalWrite(pin, LOW); //Turns off motor delay(1000); //move //Read bluetooth and write to usb if(bluetooth.available()> 0 ) // receive number from bluetooth { int ServoPos = bluetooth.read(); // Variable reads from bluetooth receiver Serial.println(servoPos); // checks value of variable ServoPos rotationServo.write(servoPos); // Rotates the servo the value received from app delay(100); } }
//shoot