Skip to content

Instantly share code, notes, and snippets.

@keathley
Created February 19, 2015 01:12
Show Gist options
  • Save keathley/80e16b28c53991124eb3 to your computer and use it in GitHub Desktop.
Save keathley/80e16b28c53991124eb3 to your computer and use it in GitHub Desktop.
a simple test to capture acceleration data from a mobile decive
<html>
<head>
</head>
<body>
<ul id="log">
</ul>
<script>
var logger = document.getElementById('log');
window.ondevicemotion = function(event) {
var ax = event.accelerationIncludingGravity.x;
var ay = event.accelerationIncludingGravity.y;
console.log(ax);
console.log(ay);
var log = document.createElement('li')
log.appendChild(document.createTextNode('ax: ' + ax + ', ay: ' + ay ));
logger.appendChild(log);
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment