Skip to content

Instantly share code, notes, and snippets.

@thomaschaaf
Created April 9, 2014 07:00
Show Gist options
  • Save thomaschaaf/10233843 to your computer and use it in GitHub Desktop.
Save thomaschaaf/10233843 to your computer and use it in GitHub Desktop.
Node.JS FTDI FT245R USB Relay FIFO A9022SLX
// 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