Kinect'ing to Arduino with Visual Basic
- Posted: Jan 13, 2012 at 6:00 AM
- 17,786 Views
- 8 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Today's Hardware Friday post is another Kinect related project, but this time using a couple things we don't see much in the Kinect space, Ardunio and Visual Basic!
In this project, I use left and right hand movements in Kinect to control the rotation of two servos tied to Arduino Uno, which in turn moves the left and right arms of a makeshift stickman. The middleware is written in Visual Basic 2010 and is based on the Microsoft Kinect SDK beta 2.
There are plenty of C++ and C# code examples to interface Kinect to other gadgets, but not many Visual Basic examples. So I figured this project could help folks with mostly VB skills to start hacking Kinect with Arduino.
HOW THIS STUFF WORKS
Kinect keeps track of 20 skeleton joints for each player. To simplify this project, I extract the coordinates of the left hand and right hand joints only. Then I pass those joint coordinates to an Arduino UNO after I do some scaling in Visual Basic from computer screen size to servo angles.
I modified the VB code in the Microsoft Quickstart samples because it's well documented and comes with good tutorials. So anyone can review these tutorials to learn more about how this VB code works with Kinect.
The changes I made to the sample VB code were mostly to facilitate serial communications with Arduino as well as to map screen coordinates to the servos angles. In this project, I capture the Y (vertical) movement of the HandLeft and HandRight joints. It should be easy to modify my code to add more servos and joints.
For this project, I used two TG9e micro servos powered by the Arduino Uno connected to my PC via USB. For bigger servos with more power needs, you may have to power them separately or else the Arduino will act erratically.
I labeled one servo as the Left Hand servo while the other as the Right Hand servo. If you confuse the servos at some point, the fix is often as simple as changing a line of code instead of rewiring.
Left Servo ---> Arduino Digital Pin 9
Right Servo ---> Arduino Digital Pin 11
For debugging purposes, you may wish to consider testing your build with one servo before adding another.
HOW TO APPLY MY CODE
In addition to the instructions, you can view my step-by-step screen captured stills. Please click the "i" in the upper left corner of each photo to see the full resolution still.
- Microsoft Kinect
- Arduino Uno
- Micro Servos X 2 (I used TG9e micro servos)
- Breadboards and wires
Arduino IDE 1.0
Microsoft Kinect SDK V1 beta2
Coding4Fun Kinect Toolkit 1.1
Microsoft Visual Basic Express 2010
.NET Framework 4
Microsoft DirectX SDK - June 2010 or later version
Runtime for Microsoft DirectX 9
Microsoft Kinect Code4Fun Quickstart VB code (You will overwrite this with my modified version)
If you're an Arduino builder, a Kinect hardware hacker or Visual Basic dev, there's a little here for all of you...