Accelerometer
4 years ago in HTML
<DOCTYPE html>
<html>
<head>
<title>Accelerometer</title>
</head>
<body>
<h1>Accelerometer Testing</h1>
<h3>X-axis: <span id="xax"></span></h3>
<h3>Y-axis: <span id="yax"></span></h3>
<h3>Z-axis: <span id="zax"></span></h3>
<script>
var acl = new Accelerometer({frequency: 60});
var x = document.getElementById("xax");
var y = document.getElementById("yax");
var z = document.getElementById("zax");
acl.addEventListener('reading', () => {
x.innerHTML = acl.x;
y.innerHTML = acl.y;
z.innerHTML = acl.z;
});
acl.start();
</script>
</body>
</html>