Created
August 29, 2013 14:23
-
-
Save elyezer/6378761 to your computer and use it in GitHub Desktop.
Beagle Bone Black HTML version of blink LED example
This file contains 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
<html> | |
<head> | |
<title>Blink an LED</title> | |
<script src="http://192.168.7.2/bonescript.js" type="text/javascript"></script> | |
<style> | |
#led_status { | |
background-color:red; | |
border-radius:16px; | |
display: inline-block; | |
height:16px; | |
width:16px | |
}; | |
</style> | |
</head> | |
<body> | |
<p>LED status: <span id="led_status"></span></p> | |
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> | |
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script> | |
<script> | |
var $led_status = $('#led_status'); | |
_bonescript.on.initialized = function () { | |
var b = require('bonescript'); | |
var ledPin = "P8_13"; | |
var ledPin2 = "USR3"; | |
b.pinMode(ledPin, b.OUTPUT); | |
b.pinMode(ledPin2, b.OUTPUT); | |
var state = b.LOW; | |
b.digitalWrite(ledPin, state); | |
b.digitalWrite(ledPin2, state); | |
setInterval(toggle, 1000); | |
function toggle() { | |
if(state == b.LOW) state = b.HIGH; | |
else state = b.LOW; | |
b.digitalWrite(ledPin, state); | |
b.digitalWrite(ledPin2, state); | |
$led_status.animate({ | |
'backgroundColor': state == b.HIGH ? 'green' : 'red' | |
}, 200); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment