How to: Arduino and Nintendo Nunchuck for pan and tilt camera interface

Hi all,

this post is an "how to" for an Arduino pan and tilt camera moved by a Nintendo Wii Nunchuck.

Here's the video so you can check how it'll be the result. The most important thing is the precision and responsiveness of the system.

Here it is for all that asked me in the past and for those interested in putting something similar in their UAVs.

It's an "old" project I've posted the following video on YouTube more than a 5 months ago but never had the time to post schematics and the code online, even if a lot of people asked for it.

I use an Arduino Diecimila board to have a Nintendo Wii Nunchuck control a camera mounted on a pan and tilt mechanism with two servos (Hitech HS-422).

Nunchuck's accelerometer (an ADXL330) is used to move the camera.

As you can see, if the Nunchuck's "Z" button is pressed, the camera position is locked.

Here is picture of the pan&tilt mechanics with servos:

First of all I got to thank a few people that before me putted their experiences online. That simple project is based on the code and infos found on the following pages:

Read wii nunchuck data into arduino

Boarduino, Wii Nunchucks, and Servos

Here's a simple schematics on how to connect the servos and Nunchuck to the Arduino. Servo's pins are 6 and 7.

The code is here.

You can find more infos about the code in the two links I mentioned before, but feel free to ask.

The only section you should customize to adapt to your servos an need is a list of variables:

refreshTime (set to 20) - minimum refresh time for servo pulse
minPulse (set to 1000) - minimum pulse value for servo 1
minPulse2 (set to 500) - minimum pulse value for servo 2
dtime (set to10) - delay (in milliseconds) for each loop
pwbuffsize (set to 10) - how many values has to be buffered and the averaged (that's the same value for both servos)

Next post will be regarding the evolution of that interface: changed camera and servos with a smaller and ligher one (this one) and made the connection between the Nunchuck and the camera, wireless.

Hope that can be helpful and feel free to ask anything about that.

Thank you and ciao,


Views: 41600

Comment by alex on June 16, 2010 at 9:49pm

If I used two arduino boards, could i make this wireless, a sender and reciever??
Comment by matthew.martori on September 1, 2011 at 7:28pm

I have a dual servo set p and everything, but when i attempt to upload your code tis happens "begin serial not defined in this scope" how do i fix this


Comment by Kevin Bezjak on September 2, 2011 at 5:47am

His code some some errors in it. You need to set the begin statements properly. It's been too long since I looked at the code to tell you off the top of my head but the syntax is wrong.

Comment by Robert Deppen on December 23, 2011 at 3:33am
I downloaded the code, but it is incomplete! Can someone please post the entire code? The one linked to on this page will not compile.
Comment by Kevin Bezjak on December 23, 2011 at 7:20am
Hey, the code is correct, but there is a few syntax errors in it. Otherwise it is fine. I cannot remember exactly but i think its the beginSerial should be serial.begin. Look up the syntax for those statements and then I think it should be okay.


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2018   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service