Skip to content

Instantly share code, notes, and snippets.

@soundanalogous
Last active March 26, 2016 03:00
Show Gist options
  • Save soundanalogous/2fbeb29c39f11498fd7f to your computer and use it in GitHub Desktop.
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)
/*
* 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