Air 2.0 Accelerometer component for MacBooks

21 12 2009

Ever wanted to build super cool Games/Applications/Demos on your MacBook using Accelerometer ?

Yes, it is now possible to build all these cool stuff with Air 2.0 & MacBook.

MacBooks have a device called SMS ( Sudden Motion Sensor ) which can act as our Accelerometer. And using Air 2.0’s NativeProcess, we can invoke a native program to give us the Accelerometer data. Here is how the flow goes:

Accelerometer Flow Chart

I got a simple C-Program called “motion” (bundled in the below package) which can give me X,Y & Z co-ordinates of Accelerometer & print on the console. I execute the process using NativeProcess API & capture the console output.

I made a wrapper class called “MBAcceleromoter” to make this entire process easier.

Click here to download the source & demo. ( Air 2.0 SDK required )

Click here to download Demo alone. ( Air 2.0 runtime required )

This package contains:

1. “motion” program to capture Accelerometer data

2. “MBAccelerometer” class to invoke & “motion” program & returned structured output through event dispatch mechanism.

3. Sample application (Accelerometer.mxml) built using APE

What are you waiting for ? Go ahead & create some amazing stuff.

Here is what I have built in this demo:

Demo – Base position

Demo – Tilted Left

Demo – Tilted Right

Advertisements