Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00d585f
commit 8a943c1
Showing
3 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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: "192.168.86.42", | ||
port: 3030 | ||
}), { | ||
samplingInterval: 100 // decrease analog read frequency | ||
}); | ||
|
||
// may take several seconds to establish a connection | ||
process.stdout.write("connecting"); | ||
var connectionProgress = setInterval(function() { | ||
process.stdout.write("."); | ||
}, 500); | ||
|
||
board.on("ready", function() { | ||
clearInterval(connectionProgress); | ||
console.log("\nREADY!"); | ||
console.log( | ||
board.firmware.name + "-" + | ||
board.firmware.version.major + "." + | ||
board.firmware.version.minor | ||
); | ||
|
||
// onboard LED and button | ||
var ledPin = 5; | ||
var buttonPin = 0; | ||
var buttonState = 1; | ||
|
||
this.pinMode(ledPin, this.MODES.OUTPUT); | ||
this.pinMode(buttonPin, this.MODES.INPUT); | ||
|
||
setInterval(function() { | ||
this.digitalWrite(ledPin, (buttonState ^= 1)); | ||
}.bind(this), 500); | ||
|
||
board.digitalRead(buttonPin, function (val) { | ||
console.log("pin " + buttonPin + " value = " + val); | ||
}); | ||
|
||
this.analogRead(0, function(val) { | ||
console.log(val); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* To run in Debug mode: DEBUG=etherport-client node wifi-test | ||
*/ | ||
var Firmata = require("firmata").Board; | ||
var EtherPort = require("etherport"); | ||
var board = new Firmata(new EtherPort(3030), { | ||
samplingInterval: 100 // decrease analog read frequency | ||
}); | ||
|
||
// may take several seconds to establish a connection | ||
process.stdout.write("connecting"); | ||
var connectionProgress = setInterval(function() { | ||
process.stdout.write("."); | ||
}, 500); | ||
|
||
board.on("ready", function() { | ||
clearInterval(connectionProgress); | ||
console.log("\nREADY!"); | ||
console.log( | ||
board.firmware.name + "-" + | ||
board.firmware.version.major + "." + | ||
board.firmware.version.minor | ||
); | ||
|
||
// onboard LED and button | ||
var ledPin = 5; | ||
var buttonPin = 0; | ||
var buttonState = 1; | ||
|
||
this.pinMode(ledPin, this.MODES.OUTPUT); | ||
this.pinMode(buttonPin, this.MODES.INPUT); | ||
|
||
setInterval(function() { | ||
this.digitalWrite(ledPin, (buttonState ^= 1)); | ||
}.bind(this), 500); | ||
|
||
board.digitalRead(buttonPin, function (val) { | ||
console.log("pin " + buttonPin + " value = " + val); | ||
}); | ||
|
||
this.analogRead(0, function(val) { | ||
console.log(val); | ||
}); | ||
|
||
}); |
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