Accelerometer code not working as it should?

Why is this code not working? It is supposed to allow me to control a ball I’ve got on my screen.

– Accelerometer
local motionx = 0
local motiony = 0

local function onAccelerate( event )
motionx = 35 * event.xGravity
motiony = 35 * event.yGravity
end
Runtime:addEventListener (“accelerometer”, onAccelerate)

local function moveball (event)
ball.x = ball.x + motionx
ball.y = ball.y - motiony
end
Runtime:addEventListener(“enterFrame”, moveball)

I’m using the Corona remote to try tilt the ball, but it wont tilt? [import]uid: 14018 topic_id: 5308 reply_id: 305308[/import]

That code looks fine. Have you tried testing on the device? I don’t know what is required to get it to work with the Corona Remote, but I think some changes need to be made. [import]uid: 10835 topic_id: 5308 reply_id: 17637[/import]

The free version CAN test on the device. Though you will need to pay the $99 to Apple for your developer certificate. [import]uid: 10835 topic_id: 5308 reply_id: 17706[/import]

Nevermind. Solved it [import]uid: 14018 topic_id: 5308 reply_id: 17705[/import]

Nice, had no idea [import]uid: 14018 topic_id: 5308 reply_id: 17712[/import]

How did you get it to work?

I tried a million times.

It wont work?

[import]uid: 51793 topic_id: 5308 reply_id: 31973[/import]

*Untested suggestion*

try looking at values of event.xGravity and event.yGravity before deciding what multiplier to use (35 in above example)
Most likely this number varies from setup to setup.

I may be wrong though… will confirm when I get back to my mac later. [import]uid: 48521 topic_id: 5308 reply_id: 32629[/import]