/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var latest = null; function doDeviceReady() { var options = { frequency: FREQUENCY_ACCEL }; watchID = navigator.accelerometer.watchAcceleration( doAcceleration, doError, options ); } function doAcceleration( acceleration ) { latest = { x: acceleration.x, y: acceleration.y }; } function doError() { alert( 'Acceleration Error' ); }
Comments
