This article describes a basic setup allowing an Arduino microcontroller board to communicate with Maya via a serial connection.
Assumptions
- You have an Arduino board.
- You have successfully uploaded sketches to it.
- You have Maya 8.5 or later, and can execute Python scripts from within Maya.
- 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.
Overview
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:
(more…)