Skip to content

Instantly share code, notes, and snippets.

@pzp1997
Created February 12, 2015 15:59
Show Gist options
  • Save pzp1997/15f65cf6b4eecaaef84b to your computer and use it in GitHub Desktop.
Save pzp1997/15f65cf6b4eecaaef84b to your computer and use it in GitHub Desktop.
Control the y-position of a circle using a MakeSense! sensor.
<!DOCTYPE html>
<html>
<head>
<title>BallSensor</title>
</head>
<body>
<canvas id="can" height="400" width="400" style="border:1px solid #000000;"></canvas>
<script>
var c = document.getElementById("can");
var ctx = c.getContext("2d");
var sensorData = 0;
setInterval(function() {
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.beginPath();
ctx.arc(ctx.canvas.width/2, sensorData, 20, 0, 2*Math.PI);
ctx.stroke();
//sensorData++;
}, 50);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment