Created
May 5, 2013 20:17
-
-
Save soundanalogous/5522039 to your computer and use it in GitHub Desktop.
BreakoutJS 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Hello World</title> | |
</head> | |
<body> | |
<button id="ledToggle">Toggle LED</button> | |
<p id="btnStatus"></p> | |
<script src="../../dist/Breakout.js"></script> | |
<script> | |
var arduino = new BO.IOBoard("localhost", 8887); | |
arduino.addEventListener(BO.IOBoardEvent.READY, function (event) { | |
var led = new BO.io.LED(arduino, arduino.getDigitalPin(11)), | |
button = new BO.io.Button(arduino, arduino.getDigitalPin(2)), | |
toggleBtn = document.getElementById("ledToggle"), | |
btnStatus = document.getElementById("btnStatus"); | |
toggleBtn.addEventListener("click", function (event) { | |
led.toggle(); | |
}); | |
button.addEventListener(BO.io.ButtonEvent.PRESS, function (event) { | |
btnStatus.innerHTML = "Button " + event.target.pinNumber + " pressed"; | |
}); | |
button.addEventListener(BO.io.ButtonEvent.RELEASE, function (event) { | |
btnStatus.innerHTML = "Button " + event.target.pinNumber + " released"; | |
}); | |
}); | |
</script> | |
</body> | |
</html>BreakoutJS example |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment