Archive for the ‘Arduino’ Category

Wii Nunchuk to Maya

Sunday, April 11th, 2010

Simple proof of concept: A Wii Nunchuk controller connected to Maya via an Arduino, which sends the Nunchuk’s accelerometer data through the serial port. Maya uses PySerial to open the serial port, reads the data, and converts it to an attribute value.

You can see that the accelerometer has quite a lot of “ring” from sharp shocks.

I based this test on Tod Kurt’s BlinkMChuck code. The Nunchuk is connected to the Arduino with this connector from Todbot. Here’s an archive containing the test files:

And here’s a link to the setup required to configure pySerial:

Code follows.

Arduino to Maya Mocap II

Saturday, August 1st, 2009

Another proof of concept: Maya processing and recording three simultaneous data streams from the Arduino at ~30 fps. There’s still only the one button on the Arduino, but I’m faking three sensors by reading and transmitting its state three times.

The keys for the spheres’ “simultaneous” state changes are never more than about 50 milliseconds apart. In every mocap test I’ve run so far, every key has wound up quantized by multiples of 10 milliseconds in the timeline, perhaps due to the pySerial sampling rate or some internal Maya clock… suspicious.

Code follows:

Basic Arduino to Maya Mocap

Wednesday, July 29th, 2009

Once again, The Mystery Hand starring in Proof of Concept: MOCAP.

I’m transmitting from the Arduino 10 times a second, which is slow enough for the Python to behave in an orderly fashion.

The Arduino code and board setup is the same as before. Highlights of the new Python code include the ability to break the script out of an otherwise infinite loop, using the GUI’s snazzy built-in progress-bar.

Code follows:

Basic Arduino to Maya III

Tuesday, July 28th, 2009

Baby steps while I bonk my head against the Maya API:

Code follows:

Basic Arduino to Maya II

Monday, July 27th, 2009

Here’s Maya reading real-time input from an Arduino board, set up in the circuit from the Arduino Button tutorial, and assuming the environment setup from my first Arduino post:

I’ve tweaked the code for the video to make the readout easier to see.

Code follows:

Basic Arduino to Maya Communication

Sunday, July 26th, 2009

This article describes a basic setup allowing an Arduino microcontroller board to communicate with Maya via a serial connection.


  1. You have an Arduino board.
  2. You have successfully uploaded sketches to it.
  3. You have Maya 8.5 or later, and can execute Python scripts from within Maya.
  4. You are running 32-bit Windows.

Disclaimer: I only barely understand why this works. If you know how these instructions could be simplified, better generalized, or otherwise improved, please comment.


Since Maya 8.5, Maya has come with an installation of Python — for Maya 2009, it’s 2.5.1, and you can run it right in the script editor. The separately-downloadable pySerial module allows Python scripts to communicate with serial devices such as the Arduino. However, pySerial requires certain files from the Python for Windows extensions, aka PyWin32. PyWin32 apparently requires that a full installation of Python be available, and pySerial requires that the Python install and the PyWin32 files be of the same version number. So, I installed Python 2.5 first, which wrote appropriate registry entries. Then I installed PyWin32 for Python 2.5, noted the paths, and installed pySerial.

After futzing with test scripts to ensure correct installation, I uploaded a sketch to Arduino which wrote “hello world” to the serial port, and ran a Python script in Maya which listened, and heard, oh yes.

Details and code follow: