The nunchuck
The nunchuck_func.h is a simple library for getting the values of the nunchuck. It's simple. Really. Just look at the code. :)
The protocol
The remote uses a special protocol to send throttle, rudder and trim-data to the helicopter. To detect data corruption, the data is secured with a checksum. Since there's no official information, one has to reverse-engineer it... Lucky for me Andrew McCubbin ↑ already did this for the PicooZ helicopters. All I had to do was to convert it to C - I'm no fan of assembly, and the atmega168 has room enough for compiled C-code.
The transmission
The signal is send using an infrared (duh) carrier, modulated using simple on/off AM on a 38kHz carrier. The ATMega is fast enough to do the modulation complete in software, but it's much nicer to use the built-in frequency-correct PWM feature for this. I used the 16-bit TIMER1 in fast PWM-mode. This isn't standard Arduino-language, but since the Arduino SDK is based on the AVR LIBC library, this is also easy. After the timer is set it's only just a matter of "connecting" and "disconnecting" the output-pin (pin 9) to the PWM-output, to send the carrier wave.
Increasing resolution
The resolution of the signals is quite low: 4 bits for throttle, and only 3 bits for the full range rudder from left to right, while the resolution of the nunchuck is much higher. By applying dithering ↑, the perceived resolution of the signal can be increased. The code uses simple error diffusion ↑ for this, and it is quite effective. The controls feel much more detailed, especially the throttle. The downside is that the helicopter seems to stutter a bit sometimes. If this bothers you, you can disable error diffusion in the code.
Combining things
Then combine all the bits. The setup initializes the output-pins, the nunchuck, and the PWM for the carrier wave. After initialization, the joystick of the nunchuck is calibrated, and the calibration data stored.
The loop reads out the nunchuck, applies the error diffusion, converts the ranges to the ranges suitable for the helicopter, and transmits the data.