Introduction: Wii Nunchuck Controlled Turret

Do you have 99 problems? Pesky squirrels? Hordes of annoying trick-or-treaters dressed as zombies? Hordes of actual zombies at your gates? Are these the types of problems that can be solved by throwing things? If so, this is the instructable for you!

To decrease you problem count, you will need:

1 Arduino Uno
2 Small Servos
Assorted Jumper Wires (or solid core and a pair of wire strippers)
1 WiiChuck Adapter
1 Nunchuck
Hot Glue
Scrap Wood (Or normal wood if you're feeling fancy)
Screws (Both the horn screws that came with the servos, and a couple of finishing screws)

This work is licensed under the Creative Commons Attribution Share-Alike.

Step 1: Build the Turret

Before I begin this step, let me say this in advance: please forgive me my woodworking on this project. I know it is horrendous. Now, on with the show!

First, I needed a base that would stay stable with all the movement that would be going on. To get this stability, I tried to make the base at least as long as the launcher bit, and added stabilizing legs on either side of it. I used a bandsaw for the plywood, an exacto for the softer balsa, and used some finishing screws (the smallest I could find) to hold it all together. Now you can see what I meant by scrap wood!

After the base was complete, I added a stem to lift the business end off the ground enough for it to move freely. To accomplish this, I used two triangles of wood I found lying around, hot glued them together, and hot glued the first servo to it. Protip: When you attach the servo, make sure it moves in the right direction before you glue it! You don't want a turret that can only aim level and into the ground ;).

Now for the turret itself. This is perhaps the worst example of my workmanship. First, I created the basic slide for the projectile, but then I realized that it was ever so slightly too wide. To remedy this, I added another sheet of balsa wood along the side. To deal with the small matter of propulsion, I affixed a rubber band to the front of the turret with a couple of small screws. However, once I had the rubber band in place, it turned out that the tension caused the dowel missile to rear up, leading me to add a screw to hold the missile down.

Finally, I cut two slots in the dowel, one in the top to hold the trigger, and one in the end to hold the rubber band. The slot I cut for the trigger was slightly too wide, so I glued a bit of balsa to the servo horn to make it wider.

Step 2: Wiring

Whenever you have any sort of actuator (servo, motor, solenoid), it's good practice to power them externally (these servos are so small I could have powered them from the Arduino, but i didn't want to risk frying anything). These servos can take anything from 4-6V (your mileage may vary, so always RTFM), so I used 4 AA batteries. Another important note for using an external power source is to tie the grounds together. It once took me 5 minutes to discover why my servos were just sitting there twitching uncontrollably, and then I realized I had neglected to connect the ground on the 'duino to the ground on the batteries.

The servos hook up in the standard fashion. I used pins 9 and 10, just out of habit. You can use whatever you want, but make sure you change the code accordingly.

The wiichuck adapter is not shown in the picture, but it is just a row of four headers that connect to A2-A5. Because the nunchuck is a manufactured device, you can be sure that it won't draw enough current to fry your analog pins, so you can use A2 and A3 to provide power. A4 and A5, as always, provide data and clock for I2C communication with the nunchuck.

Step 3: Code

All files can be found here on github.

To interface with the nunchuck, I modified todbot's library for use in my program. To get a nice, clean reading from the accelerometer, I used the digitalSmooth function from the Arduino Playground, originally written by Paul Badger.

The main code is pretty simple. It gets the reading from the accelerometer, confines it to a range, smooths it, and then maps it to an angle. Then it sets the aiming servo to that angle, and checks whether any buttons on the wiichuck have been pressed. The small one on top (c) closed the trigger, and the big one on the bottom (z), opens it.

To set up this code, you have to:
1) Ensure all the pin declarations are OK.
2) Run BallisticDuino_Calibration, and play with the offset values so that the servo is level, and the trigger closes on the dowel without being blocked by anything. Then, change the second line in loop() to trigger.write(triggerOpenAngle), and mess with that value until the trigger is open and not bumping into anything. Copy these values into the Nunchuck_Turret sketch.
3) Upload and run Nunchuck_Turret. Open the serial monitor and find what value the nunchuck reads when you point it straight up, and what value it reads when it is level. Enter these into the sketch.

You should be good to go!

Step 4: Enjoy!

You are now the proud owner of an arduino controlled projectile weapon! Use this newfound power responsibly!

Here is a video demo of the turret in action.


LosAlfajores (author)2013-07-20

Well, you inspired me to do my own version of this project!


skorpijon (author)2013-06-26

Super, great instructable. I love it ;)

britknight (author)skorpijon2013-06-27