Created
February 12, 2015 15:59
-
-
Save pzp1997/15f65cf6b4eecaaef84b to your computer and use it in GitHub Desktop.
Control the y-position of a circle using a MakeSense! sensor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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