
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. Extract it to “. . ./Applications/Processing 0118/libraries” and you will have the following files:
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
23 Responses to “Processing Sudden Motion Sensor Library”
- 1 Pingback on Nov 14th, 2006 at 5:02 am
- 2 Pingback on Jan 9th, 2007 at 5:27 am
- 3 Pingback on May 23rd, 2007 at 8:02 am
- 4 Pingback on Sep 29th, 2007 at 4:49 pm
- 5 Pingback on Dec 10th, 2007 at 1:35 pm
seems to work in my black macbook. Thanks!
i’ve installed it but how to make it work?
with the code in the example I get :
java.lang.UnsupportedClassVersionError: sms/Unimotion (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
Thanks!
I did a quick check on my MacBook. I just threw up a couple lines moving about. It works great.
The only wierd thing was it said:
>Detecting SMS
>Detected SMS type 4 (macbookpro)
Whereas I’m on a MacBook. But this is such a minor detail I could care less.
I have no AppleNote. And I become to want to get one.
Now,
What is the returned value? Location, Velocity, Acceleration?
douglas - the message is generated by unimotion’s sms type detection code. check out unimotion.c (in daniel’s src folder) and search for “macbookpro”. unimotion seems to label all macbooks (sms hardware type 4) as “macbookpro”. no biggie.
Tested on a 2 GHz intel Core Duo MacBoo Pro running Mac OS X v10.4.8. Works sweetly!
Yeah, it even works on an iBook G4 bought in August 2005. Thanks!
It’s working great on my MacBook Pro. I made a game called Tilt SCREAM Pong. http://futurefeeder.com/index.php/archives/2007/01/02/tilt-scream-pong/
Hey people,
I downloaded the zip file to my desktop, does anyone know how to set it up so i can use the library in eclipse??
Its ok i answered my own question, just needed to set a build path. If anyone needs specifics just leave a post.
I’m getting the same error
java.lang.UnsupportedClassVersionError: sms/Unimotion (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
Dan: Are you on a PC by any chance? The library won’t work on a PC. Otherwise, let me know your Mac OS version, Processing version, etc. . .
hi
amazing work!
just one question. have you ever tried to work with the environment light sensor. or can you tell me how i can get the lightsensor data in flash.
i would be glad for any hint
alex
oh yeah - accessing the environment light sensor in java would be sweet - though I have to admint that I haven’t really looked at this matter yet - well possible that there is already some way to do that…
hi. for everyone who wants to use the light sensor. a friend of mine hast developed such an api and but it on his blog:
http://blog.formatlos.com
have fun
This article writes extremely well, I like very much, later I will be able to come here to have a look,Comes here to support your.
Hi, this is great. I just wrote a sketch that does spectrum analysis (with the FFT class from Krister Olsson’s Ess library) on the output of the motion sensors. It was interesting to see how even the vibration of the internal hard drive shows up as a spike in the spectrum. Nevertheless, it’s hard to say how much of the output is sensor noise.
Then again, the sensors do seem to be pretty darn sensitive. My typing makes the Z sensor go wild…
Hello,
How I can use it using Ecplise?
Thanks,
Lucio.