Introduction: Nunchuk-controlled Helicopter

Picture of Nunchuk-controlled Helicopter
Welcome to my 3rd Instructable everyone !

Today we're going to build a 'device' to control a mini-sized helicopter with a Wii Nunchuk.
The helicopter that we're using is a cheap (26$) 3-channel (yaw, throttle, pitch) helicopter that I bought a 1 month back from . I can say that it is a VERY durable heli : I have crashed more thant 100 times and it's still working ! It is not radio-controlled, but rather Infrared-controlled, so easier to reverse-engineer. I should also say that in this instructable, the original remote won't be harmed, everything can be done without opening it or even opening the helicopter itself. That means we have nothing to lose :D

In this instructable we're going to take a look at reverse-engineering the Infrared communication with a IR demodulator (very cheap), we'll also learn to use our beloved Arduino as a 1Mhz 'full-featured' logic analyzer. Finally, at the end, there's loads of fun flying the heli around with a nunchuk !

But be warned : as I'm away from home, I won't be able to provide you with a clean PCB to arrange all the components, this is more a quick-and-dirty hack than a real (and finished) project.

Please rate this Instructable ! And also, if you're actually building the thing (or have problems building it), please post a quick comment, I'm always happy to learn I've helped people out !

If you're in, let's go : step 1, the required stuff

Step 1: Required Stuff

Picture of Required Stuff

Required tools:

- soldering iron
- solder wire

Required parts:

- Arduino (I use a Mega, but any Arduino will be just fine)
- Mini-Helicopter (This project can easely be ported to work on a Syma S107, and any other heli if you reverse-engineer the IR pulse yourself)
- Wii Nunchuk
- 9v battery with 9v battery clip an jack
- TIP120 transistor
- 38kHz IR detector/demodulator
- 10kOhm potentiometer
- 10 ohm resistor
- 4x AA batteries
- 4x AA battery holder (optional, used if you don't want to break your original remote)
- 3x IR leds (used if you don't want to break your original remote)

Required software (for now) :

- Arduino IDE, get it here
- SUMP OpenLogicSniffer client (special version), get it here .

Ok, I think everything's here, so let's head to step 2...

Step 2: Infrared Modulation

Picture of Infrared Modulation

Now, this is the theory, if you don't want to know how to reverse-engineer an IR remote control, you can just skip to step 6.

Ok, so the helicopter isn't controlled with a 'normal' radio remote, but is controlled with a cheaper Infrared remote.
This is just great because we can more easely reverse-engineer the thing ! We only need a component called an IR detector or IR demodulator.
Now this page has an excellent tutorial on how infrared modulation works, but I'm only going to resume it quickly here :

As you know, the sun, as well as most heat sources, including light bulbs, emits infrared radiation. Infrared modulation is a technique that involves PWM-ing an Infrared led at a certain frequency (here 38kHz) to 'bypass' the IR radiation from ambient light : the IR demodulator only accepts 38kHz modulation, filters out everything else, and gives a clean logic (0 or 1) output. It gives a logic LOW (0volts) output when it detects a modulated IR signal.
There's a device like this on all TVs/DVRs/DVD players, etc.. Fortunately, this thing doesn't cost much , is really easy to interface with a microcontroller/logic analyzer and will allow us to reverse-engineer the IR protocol used by our helicopter remote without opening the remote !

BTW, the image below kinda illustrates well how IR modulation works : the remote gives the signal on the left, the demodulator gives the one on the right.

Now let's move on to step three : preparing our improvised 'logic analyzer' .

Step 3: Preparing the Logic Analyzer

Picture of Preparing the Logic Analyzer

So now, you know how the transmission physically works, and what the demodulator will output. It outputs logic HIGH (5v) when no signal is detected, and logic LOW (0v) when a modulated signal is detected. All right, enough theory. How are we going to record and use this signal ? We need a logic analyzer. Unfortunately, these types of tools don't come cheap (~150$ for the Logic ), but the Arduino community really has a lot to give, and someone named gillham made an Arduino sketch that transforms the Arduino into a SUMP-compatible 1MHz logic analyzer. Yeah, 1MHz isn't brilliant, but hey, it's free, and it will suffice for our light use.

- You have normally already downloaded the modified SUMP client in Step 1. If not, here it is.
- You'll also need the logic_analyzer.pde Arduino sketch
- Connect the IR demodulator's data pin (the one on the left) to the Arduino's pin 8.
- Connect the demodulator's GND (middle pin) to the Arduino's GND
- Connect the demodulator's Vcc (Right pin) to the Arduino's 5v supply.
- Extract the OLS zip, connect your arduino via usb, and execute the run.bat (if you're under windows) or (if you're on linux).
- Now hit the 'Begin capture' button, select the serial port your arduino is using, choose 115200bps speed
- In the 'device type', choose the "Arduino Generic Logic Analyzer" profile.
- In the 'Acquisition' tab, choose 20kHz sampling rate, check the 'automatic recording size' checkbox.
- In the 'Triggers' tab, enable the triggers, and in all the checkboxes on the bottom, check the top-right one.
- Now click the 'Capture' button and raise the throttle on the heli's remote.
- If you have any problems, post a comment, I'll help you. ;)

Note: You can get a sort of 'manual' on the OLS here , and also, I apologize for the poor image quality, but this is caused because compresses uploaded images. :(

Ok, so everything is ready, let's dive in ! Step 4: Capturing IR pulses...

Step 4: Capturing IR Packets

Picture of Capturing IR Packets

All right, so now that your 'logic analyzer' is ready to go, we're going to start the actual reverse-engineering : 'intercept' the IR signal that goes from the remote to the helicopter. In the next step, I'll attempt to decode this signal, and create one from the Arduino.

So just click on the capture button, and crank up the throttle on your remote. Zoom in a little bit, and you'll see a signal like in picture 1. The signal is read from right to left
- As you see there are times when the 'ON' period is long, and times where it's short. At the beginning, there's a very long 'ON' period, we'll deal with that later.
- Right-click on one falling edge of the short 'ON' signal, select set cursor 1 (for better precision, use the zoom)
- Right click on the corresponding rising edge, select set cursor 2 (see pic2)
- Now go to Tools-->Measure, check the 'Distance' value, and write it down : write short_ON=[distancevalue] in a txt file.
- Do the same thing for the 'OFF' (check pic3), and write down : OFF=[distancevalue]
- Do the same thing for the long 'ON' period, and write down : long_ON=[distancevalue] (see pic4)
- The very long 'ON' period at the beginning of the signal is called a header. Measure it, and write down : head_ON=[distancevalue]

But now, how will we decode the binary stream (0s and 1s) sent by the remote? One would think that a 'ON' period is a 1 and an 'OFF' period is a 0. But then, why are there longer 'ON' periods, and why are all the 'OFF' periods the same size? The reason is that :
- a 1 is a long 'ON' period followed by an 'OFF' period (see pic4)
- a 0 is a short 'ON' period followed by an 'OFF' period

Now that we have figured out how to 'translate' this IR signal into a series of 1s and 0s, we still need to know which 0s and 1s control which part of the heli (the yaw, pitch, etc...). For this, we will try to write down that series of 1s and 0s in every possible configuration of the remote, (e.g. Full throttle-yaw centered, then Full throttle-yaw to the right, then Full throttle-yaw to the left, etc...). Then we can figure out which combination of 1s and 0s corresponds to which part of the heli, by seeing which 0s and 1s change in which remote configuration. Now, to better see the changes of the 1s and 0s, we can color them differently using a intelligent notepad. I made it under notepad++ in windows (you can use it with wine on linux). At the end, I got a text file looking like picture 6. Then I tried to decode it and made another text file describing which helicopter components were affected to which bits : here it is.

With this info, you should be capable of reverse-engineering the IR protocol of any similar helicopter. If you do, please post a comment so I can integrate it in this instructable.

Next step is recreating this IR pulse in Arduino. Ready, let's go !

Step 5: The Arduino Sketch

Picture of The Arduino Sketch

So, um, well, I'm not really going to explain how the code works here, but, all I can say is that to generate the IR pulses, I got the code from this blog, that I heavily modified to work with my heli, and then I got the nunchuk handling part from Tod E. Kurt ( and used it to control the heli.

To send an IR packet, you call this function :
SendCommand(throttle, yaw, pitch, trim);
- throttle 0-255
- yaw 0-255
- pitch : 1=backwards, 2=forward, 0=none
- trim 0-255

So don't forget to read the description at the beginning of the code, an that's pretty much it !
Oh, I almost forgot ! You can get the code here ^^

Now, let's head to step 6 : the hardware setup.

Step 6: The Hardware Setup

Picture of The Hardware Setup

Okay, now that we're done on the software side, we will focus on building the hardware that goes with it. As I said in the Introduction, I'm currently away from home (and for a long time), and I don't have access to my laserprinter, that means that you won't get a clean pcb this time :'( Indeed, the hardware setup here is kinda messy.
- Due to the low discharge rate of 9v batteries, I prefer using a separate power supply for the leds, to avoid any brown-outs on the arduino. Here, I just used the old remote's case because of it's battery holder. If you want a cleaner layout, just buy a battery holder . I use 4 AA batteries to power the leds.
Now for the wiring (take a deep breath) :

- chop off the nunchuk's connector (or use this)
- connect the nunchuk's red wire (Vcc) to the arduino's 5v supply
- connect the nunchuk's white wire (gnd) to the arduino's GND
- connect the nunchuk's green wire (SDA) to the arduino's Analog pin 4
- connect the nunchuk's yellow wire (SCL) to the arduino's analog pin 5
- connect the 3 IR leds in series, with the 10 Ohm resistor to the external supply's +
- connect the IR leds cathode with the TIP120's collector (middle pin)
- connect the TIP120's emitter (right pin) to the arduino's GND
- connect the Arduino's GND to the external supply's -
- connect the TIP120's base (left pin) to arduino digital pin 2
- connect the potentiometer's left wire to the arduino's 5v supply
- connect the pot's right wire to the arduino's GND
- connect the pot's middle wire to arduino analog pin 0
- connect the 9v battery to its clip and plug it in the arduino's power jack.

- check the picture for any errors.

Now program your Arduino, and head to step 7 to begin having fun (finally !)

Step 7: Controlling the Helicopter

Picture of Controlling the Helicopter

Enough work ! No, really, YOU need a break ;) In this step, I'll explain how to control your Helicopter with your freshly-wired system.

- The nunchuk's C button (the little round one) is the Dead Man's switch. Always have it pushed down. If you release it, the Helicopter will receive the Stop command and will stop moving it's blades.
- You control the throttle (up/down) by tilting the nunchuk forward and backwards
- The joystick's X axis controls the Yaw (left/right)
- The joystick's Y axis controls the pitch (forward/backwards)

So this instructable is coming to an end, but stay tuned, because I'm currently building another remote for the heli, but this time, I'll be using an Android smartphone as the remote (It will be ready in 1 or 2 months)

- All right, so now, Have Fun ! (and spread the word ^^)


mike3137 (author)2014-12-25

Is there a on and off switch on the helicopter it self

mike3137 (author)2014-12-25

Is there a on and off switch on the helicopter it self

mike3137 (author)2014-12-25

Is there a on and off switch on the helicopter it self

mike3137 (author)2014-12-25

Is there a on and off switch on the helicopter it self

mike3137 (author)2014-12-25

Is there a on and off switch on the helicopter it self

mike3137 (author)2014-12-25

I charged the battery go to use it and there is nothing

cct424 (author)2014-03-02

i follow the step but found that the code have error.. so what should i do? im using arduino uno...

NickWayne (author)2013-11-21

Sweet tutorial! I'm new to all of this so bear with my questions. If I wanted to, would I be able to instead code in to control the heli by my computer via keypress? If so could you please kind of show me what that would look like in the code (throttle, pitch, yaw, trim, the kill switch, and if possible could you show me what a code for 'hover' on keypress would look like)? Also would I just keep the USB connected to run it all or would I have to run a different connection? Thank you for your time!

bgantaume (author)2013-09-24

Hi, Thaks a lot!

a1r (author)bgantaume2013-09-25

You're welcome dude ;)

GabrielH (author)2012-12-06

I have a Syma S107, do I need to change the Arduino code in any way? I am using Arduino Uno R3 - software 1.0.2.

a1r (author)GabrielH2012-12-07

Yep, at first my code was based on the syma s107 protocol. I don't have the time to make a syma s107 version, but the only thing you need to mod is the send fuction. You can grab the send function for the syma s107 here:

Birdy42 (author)2012-07-31

Hi thx for your tutorial

I can't open run.bat when i click on it it close itself right away
I have the last version of java
Runing on windows 7 64
Try with compaibility xp service pack (1-2-3)
Try to download zip file again

But still nothing

I have no ...

Anyone? thx

gl1tch (author)2012-01-23

First many thanks on this instructable, wanted to do something similar and do not even know where to start.

At this very step after i started the capture with OLS which is always aborted with the following error.

"Capture aborted! Duplicate key: 0x30!"

And i do not know how to go from here at all :(
I am using a Arduino Deumilanove and the latest arduino IDE v1, and i get the same error rather i am on Windows or Ubuntu. Any thoughts on why this is happening?

amquad (author)gl1tch2012-02-06

Had the same problem Found I needed a new Arduino file

Downloaded at

Works fine now. Hope this helps others :-)

gl1tch (author)amquad2012-02-11

Nice, thank you that totally solved the problem =)

Gibber8 (author)2011-12-09

Thanks for the inspiration!

I decided to try this with a helicopter that looks identical to yours but the Brand name is Xinxun and the model is X-02. From what I could see, the remote looks identical as well but looks seems to be where the similarity ends.

My remote has a switch next to the right stick labeled I/II. This provides high or low rate for the pitch motor. It also has a button labelled "change" that both changes the "band" of operation as indicated by the three LEDs just above the power indicator, and also turns the LED headlight on the heli on or off.

The IR pulse arrangement is completely different. Mine uses a series of 41 pulses. Each pulse is represented in the IR stream by either high (1) or low (0) (38 kHz off or on) state with a 0 being 450 microseconds long and a 1 being 900 microseconds. There are 6 bits each for throttle, yaw, trim and pitch, 4 unused bits (always 0), 2 bits to encode which "band" the remote and heli are operating on, one bit to send the status of the pitch dual rate switch, one bit to send the status of the change button, and then 9 bits that change depending on the values of the previous 32 bits, sort of like a checksum or encryption key.

This is the part I have not figured out yet. I can duplicate a sequence of pulses that I have captured using the logic analyser and the heli will decode it but I don't know how to code those last 9 bits for any variable pulse stream as generated by the nunchuck inputs. If the last 9 bits are not correctly set the heli just ignores that series of pulses and shuts down.

If anyone else has run into this type of coding and sorted it out please respond back.

a1r (author)Gibber82011-12-16

Can you post a screenshot of the captured IR pulse. I'll see if I can help you.

Gibber8 (author)a1r2011-12-21

I have attached a screen shot of the pulse from logic sniffer, captured when throttle = minimum, yaw and pitch = neutral, trim = max left, and hi/lo rate = lo. The pulse reads (000000 000000 011111 000000 000001 000011 01010) Note that I added the spaces to make transcribing easier.

I thing I almost have it figured out. The last bit is always 0 so that leaves 8 bits to decode and it looks like these are a combination of the four variables. I just need to determine if the combination is boolean and if so what (and, or, xor),

Thanks for your time.

a1r (author)Gibber82011-12-22

Sorry, I forgot to mention: compresses images, so I can't really see the pulse on your screenshot. You could try to send it directly to my email: john.a1rstudios at . And, could you include a link to where you bought your heli ?

golaky (author)2011-12-20

Thanks a lot ,now the OLS works but nothing append, i follow all your instruction and i tested with an oscilloscope and with another analyzer the pin data of the IR demodulator and i can see an output but not over arduino and OLS.

a1r (author)golaky2011-12-20

I'm sorry it's not working. Maybe check that the baud rate in the arduino sketch and ols are the same ? Is your other analyzer computer-based ? Can you send me a screenshot of the pulse or even a photo of the analyzer's screen ?

golaky (author)2011-12-19

Thanks for the great idea.
I'll try to capture the data but i got allways fro ols programm the following error:
Device type dos not match selected type!......
I'm using arduino mega.
Can you help me?

a1r (author)golaky2011-12-19

Yup, I can help. If you have an Arduino mega, all you need is a Arduino Mega profile. Here it is. Put the file in the [OLS Folder]/plugins directory and restart ols. next, in the capture window, in the "Device type", select the "Arduino Mega Logic Analyzer, and click ok. Voila !

Mic100 (author)2011-11-15

I'm French to and my english in not very good !

I've made an Arduino Severino (It is pin-compatible with the Arduino Diecimila) with ATmega 168, i've tested it with processing and it work fine. this pcb has no USB port but a serial RS232 interface.
I've compiled your program under Arduino without the makefile and I uploaded it I run the sniffer but when I start the acquisition, he said device not found my question is is it because my arduino does not have a USB port?

Thank you for this Instructables :)

a1r (author)Mic1002011-11-16

Normalement, ca devrait marcher. En fait, essaye de trouver le port serie auquel est connecte ton arduino (COM1, COM2, un truc comme ca). Et quand tu ouvres la fenetre d'aquisition, selectionne ce port.

Mic100 (author)a1r2011-11-19

OK merci je vais faire des essais :)

carlsands (author)2011-11-11

well that would make controling the rc helicopter easier

francisroan (author)2011-11-09

can we use the accelerometer in the nunchuck?

a1r (author)francisroan2011-11-09

Yes ! In fact, it is already used to control the heli's throttle (up/down). If you don't have a heli, just connect your arduino to your pc and switch on the serial port to 115200 baud, I've included a debug output in the code.

 If you want to control the heli's pitch/yaw with the accelerometer and throttle with the joystick, you have to:

- change some variable names in the heli_funcs.h file :
    - change all the accy occurences with joyy in SetAbsoluteAltitude()
    - change all the joyy occurences with accy in SetPitch()
- remove the accelerometer Y-axis inversion command ( accy = map(accy, 0, 255, 255, 0); )
- call SendCommand(altitude, accx, pitch, pot);

I hope it helped you... Let me know if you have any problems, I always answer ;)

nerd7473 (author)2011-11-02

good use for the wii nunchuck

Timboscoops (author)2011-11-01

ever think of adding a camera? so youd see first person on your andriod

a1r (author)Timboscoops2011-11-02

Yup, but that will be part of a bigger project ;)

theawesomedude92 (author)2011-11-01

Can this work with the classic controller? I would really like to know, great mod. =)

a1r (author)theawesomedude922011-11-01

Um, no (not yet). But it is relatively easy to modify the code to work with one. Just search on the arduino forums. Good luck man !

About This Instructable




Bio: My name is Jonathan Rico, I'm 18 and I live in France.I'm in my first year of an electronics degree. And, the ... More »
More by a1r:WiFi Stunt CarNunchuk-controlled HelicopterAndroid RC Car
Add instructable to: