Processing Sudden Motion Sensor Library
Thanks to the open source Unimotion library by Lincoln Ramsay, I have developed a java native interface that allows access to the Apple Sudden Motion Sensor available in powerbooks (and macbooks) since 2005.
Download the library sms.zip. Source code for unimotion.c and Unimotion.java is contained in the src directory.
Available functions:
// Return x, y, and z values as array
public static int[] getSMSArray();
// Return just the X
public static int getSMSX();
// Return just the Y
public static int getSMSY();
// Return just the Z
public static int getSMSZ();
Example code:
import sms.*;
void setup() {
size(200,200);
}
void draw() {
int[] vals = Unimotion.getSMSArray();
println(vals[0] + " " + vals[1] + " " + vals[2]);
}
History of Motion