daniel shiffman

Processing Sudden Motion Sensor Library

SMS Axes

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

  • Written by Christian Klein
  • JNI Implementation of motion by Dave Chatting
  • Modified for iBook compatibility by Pall Thayer
  • Modified for Hi Res Powerbook compatibility by Pall Thayer
  • Modified for MacBook Pro compatibility by Randy Green
  • Disparate forks unified into UniMotion by Lincoln Ramsay
  • Made into a Java Native Interface by Daniel Shiffman
  • comments powered by Disqus