"Fun with the iPhone accelerometer"

Tinman

Evangelist
Gold
Jul 16, 2007
4,334
183
63
Aridzona
#1
Apparently the iPhone's accelerometer is much more robust than I thought. It doesn't just spit out a one bit response (i.e., landscape or portrait). While this is all that is available via Safari apps (e.g., the game "Tilt") it isn't all there is (watch for the ball-in-maze game!):



"As it turns out, the iPhone has a built-in LIS302DL, a tiny 3-axis accelerometer. While some have attempted to use it from within the Safari browser (the Tilt game detects changes to the width of the browser page; it is basically used as a 1-bit input device), its potential is still somewhat untapped. . ."
http://blog.medallia.com/2007/08/fun_with_the_iphone_accelerome.html

To get an idea for how much data the accelerometor actully spits out, you can try this app:
http://www.tokash.org/iPhone/AccTest.zip

I would LOVE to see games and apps take advantage of this! A marble maze game would be perfect.


--
Mike
 

Velodog2

Member
Silver
Jul 19, 2007
562
0
16
#2
I'm probably the only one who cares, but why is this device universally called an accelerometer when it isn't? It clearly detects gravity, not acceleration.

Or, possibly, acceleration of something due to gravity, but certainly not simply acceleration.
 

jswan

New Member
Mar 20, 2007
19
0
0
#3
I'm probably the only one who cares, but why is this device universally called an accelerometer when it isn't? It clearly detects gravity, not acceleration.

Or, possibly, acceleration of something due to gravity, but certainly not simply acceleration.
Because to the device, gravity is indistinguishable from acceleration. If the device were in an environment with no gravity, you could replicate the pull of gravity by accelerating the iPhone in a certain direction. So the device doesn't detect "gravity"--it detects acceleration (or, more accurately, it detects forces that push the device one way or the other).
 

Velodog2

Member
Silver
Jul 19, 2007
562
0
16
#4
Because to the device, gravity is indistinguishable from acceleration. If the device were in an environment with no gravity, you could replicate the pull of gravity by accelerating the iPhone in a certain direction. So the device doesn't detect "gravity"--it detects acceleration (or, more accurately, it detects forces that push the device one way or the other).
au contraire. Just the opposite in fact. If what you say was the case then rotating it flat on a table top should have the same effect as turning it from portrait to landscape when held upright. It doesn't, because it detects gravity, not acceleration.
 

Tinman

Evangelist
Gold
Jul 16, 2007
4,334
183
63
Aridzona
#5
I'm probably the only one who cares, but why is this device universally called an accelerometer when it isn't? It clearly detects gravity, not acceleration.

Or, possibly, acceleration of something due to gravity, but certainly not simply acceleration.
The manufacturer calls it an accelerometer, and I see no reason to doubt them:
"The LIS302DL is an ultra compact low-power three axes linear accelerometer. It includes a sensing element and an IC interface able to provide the measured acceleration to the external world through I2C/SPI serial interface..."
http://www.st.com/stonline/products/literature/ds/12726.pdf

As for gravity:
"What is an accelerometer?
An accelerometer is an electromechanical device that will measure acceleration forces. These forces may be static, like the constant force of gravity[b/] pulling at your feet, or they could be dynamic - caused by moving or vibrating the accelerometer.

What are accelerometers useful for?
By measuring the amount of static acceleration due to gravity, you can find out the angle the device is tilted at with respect to the earth. By sensing the amount of dynamic acceleration, you can analyze the way the device is moving."


--
Mike
 

Velodog2

Member
Silver
Jul 19, 2007
562
0
16
#6
Yah, I know, i just wikied the term and find that it is generically used to describe both types of devices. So common usage wins out over absolute accuracy. Nonetheless, there is a specific term for an accelerometer used to detect gravity: gravimeter. I say let's all use this term from now on.

Lol, kidding.
 

jswan

New Member
Mar 20, 2007
19
0
0
#7
au contraire. Just the opposite in fact. If what you say was the case then rotating it flat on a table top should have the same effect as turning it from portrait to landscape when held upright. It doesn't, because it detects gravity, not acceleration.
No. It detects acceleration forces. These include gravity.

When the iPhone is flat on a table, it's detecting acceleration forces (gravity) pushing it into the table. When you spin it around, it detects very slight acceleration forces pushing down on one side, up on the other, and out from the center, but by far the strongest force pushing on it is still gravity, pushing down into the table.

When the iPhone is upright in your hand, it's detecting acceleration forces (gravity) pushing it down towards the ground. When you spin it around, it detects (again) the slight acceleration forces from the rotation, but the strongest force (gravity) pushes down, towards the ground. When the angle of the phone changes, the strongest force is now pushing in a different direction relative to the phone, so the screen changes.


Basically, gravity is the same, force-wise, as acceleration. Just imagine that your iPhone is constantly accelerating upwards at a rate of 9.8 m/s/s. The accelerometer detects this acceleration and its direction relative to the screen and adjusts the display accordingly.
 

jeepshots

Member
Bronze
Jul 10, 2007
68
0
6
#9
Awwww heck! If this pans out like I think it's gonna, I'm gonna HAV'TA mod my iPhone. And yes, a level application would be sooo cool. Have a Vertical or Horizontal flipswitch to flip the bubble indicator, and have the accelerometer control the bubble itself. Very doable in my opinion. I just don't know how to do it. :laugh2:
 

Tinman

Evangelist
Gold
Jul 16, 2007
4,334
183
63
Aridzona
#10
Awwww heck! If this pans out like I think it's gonna, I'm gonna HAV'TA mod my iPhone. And yes, a level application would be sooo cool. Have a Vertical or Horizontal flipswitch to flip the bubble indicator, and have the accelerometer control the bubble itself. Very doable in my opinion. I just don't know how to do it. :laugh2:
I'd day it is definitely doable. Try installing the app I linked to above. The granularity is amazing.


--
Mike
 

Velodog2

Member
Silver
Jul 19, 2007
562
0
16
#11
Wow this is unexpectedly cool stuff.

Not thinking of apps other than those mentioned, but I'm not very imaginative. Game opportunities abound of course. Love the idea of animating a bubble on the screen to use it as a spirit level, but it could also work as a 2 axis level (rather than just vertical and horizontal) by laying it flat and centering the bubble on the screen. I suppose it could have some utility in flying a plane to keep the wings level...
 

Tinman

Evangelist
Gold
Jul 16, 2007
4,334
183
63
Aridzona
#14
That would be cool on the iPhone, and I bet it could be done.

With my iPhone flat on the table the data from the accelerometer jumps if I just hit the corner of the desk. Very sensitive.

An alarm app would be cool too: iPhone emits an alarm sound if someone walks into the room, bumps table that iPhone is on, disturbs iPhone in any way, etc.

Then of course there's using it to for controlling, say, NES and other games (like a Wii remote). Tilt left to go left, etc.

Lots of cool possibilities here!


--
Mike
 

Alexander

Zealot
Gold
Jun 28, 2007
1,724
0
36
Atlanta
#15
I agree. I was personally afraid the accelerometer was very 2 dimensional (i.e. just switches from portrait to landscape with no "in between"). This really does unlock a lot more possibilities, which is especially good when the iPhone's original novelty begins to wear off.