Accelerometer - up and down movement

Hi 

I’m trying to make use of the accelerometer, but just can’t seem to understand its logic. I would like to trigger and action, if the player moves the phone up or down. Pretty simple. On the begining I tryed with 

zAcc = event.zInstant

But this didn’t give precise results. Even if I moved the phone downwards, the result was positive. And vice versa. Then I tryed this one.

local function onAccelerate( event ) zAcc = math.sqrt( event.zInstant \* event.zInstant + event.xInstant \* event.xInstant ) if ( event.zInstant \< 0 ) and ( event.xInstant \> 0 ) then zAcc = - zAcc else zAcc = zAcc end phoneAngle = math.deg( math.atan( event.zGravity/event.xGravity ) ) end 

But here I’m having difficulties to get the direction of phone movement. How do I know when zAcc is positive or negative? 

One more question I couldn’t figure out. Is event.zInstant(and of course the other two, x and y) absolute to the phone? So if I change the angle of the phone it does not change? Or is it fixed to the gravity?