Created
April 9, 2014 07:00
-
-
Save thomaschaaf/10233843 to your computer and use it in GitHub Desktop.
Node.JS FTDI FT245R USB Relay FIFO A9022SLX
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
// npm install ftdi | |
var ftdi = require('ftdi'); | |
ftdi.find(function(err, devices) { | |
var device = new ftdi.FtdiDevice(devices[0]); | |
device.on('error', function(err) { | |
console.log(err); | |
}); | |
device.open({ | |
baudrate: 9600, | |
databits: 8, | |
stopbits: 1, | |
parity: 'none' | |
}, | |
function(err) { | |
device.on('data', function(data) { | |
}); | |
var ON = 1; | |
var OFF = 0; | |
var array = new Array(ON, ON, OFF, ON).reverse(); | |
console.log(array.join("")); | |
device.write([parseInt(array.join(""), 2)], function(err) { | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment