Control Velleman K8061 interface board with node.js.
- node.js
- libusb
- Velleman K8061 USB interface board
npm install git://github.com/unkernet/node-k8061.gitvar k8061 = require('node-k8061');
var count = k8061.count;
console.log('Found ' + count + ' devices');
if (count > 0) {
try {
var board = k8061.k8061(); // Open the first available device
} catch (e) {
console.error(e.message);
process.exit();
}
board.analogOut = 128; // Set all analog channels to the middle value
board.analogOut[7] = 255; // Set last analog channels to the maximum value
setInterval(function() {
board.digitalOut = board.digitalIn;
}, 100); // Bind digital output to the digital input
}countNumber of connected boards.k8061(id, byAddress)Open the device with specified id by connection order or by address jumpers.
close()Close the device.hasPower1 if the board is connected to an external power source.digitalInArray of digital input pins, 0 or 1.digitalOutArray of digital output pins, 0 or 1. Can be set to an array or a single value.analogInArray of digital input pins, 0 to 1023.analogOutArray of digital output pins, 0 to 255. Can be set to an array or a single value.pwmOutPWM output value, 0 to 1023.