Last active
March 26, 2016 03:00
-
-
Save soundanalogous/2fbeb29c39f11498fd7f to your computer and use it in GitHub Desktop.
simple example to test StandardFirmataWiFi (wire an LED to pin D8 and a potentiometer to pin A0)
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
/* | |
* Tested using node v0.12.7 | |
* npm install etherport-client | |
* npm install firmata | |
* | |
* To run in Debug mode: | |
* DEBUG=etherport-client node wifi-test | |
*/ | |
var Firmata = require("firmata").Board; | |
var EtherPortClient = require("etherport-client").EtherPortClient; | |
var board = new Firmata(new EtherPortClient({ | |
host: "10.0.0.39", | |
port: 3030 | |
})); | |
board.on("ready", function() { | |
console.log("READY!"); | |
console.log( | |
board.firmware.name + "-" + | |
board.firmware.version.major + "." + | |
board.firmware.version.minor | |
); | |
var state = 1; | |
var lastVal = 0; | |
this.pinMode(8, this.MODES.OUTPUT); | |
setInterval(function() { | |
this.digitalWrite(8, (state ^= 1)); | |
}.bind(this), 500); | |
this.analogRead(0, function(value) { | |
if (value != lastVal) { | |
console.log(value); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment