0

I am trying to access the HID(Human interface devices) using node-hid npm in node. i want to start the light when my node app is run. But when i pass the data it is not working. i want to start the white leds when my node app start and based on my selection it should change the color.

Can anybody guide me how i can start rgb led using node-hid?

'use strict';

var HID = require('../');
var VENDOR_ID = 0000; // device vender_id
var PRODUCT_ID = 0000; // device product_id

var devices_found = HID.devices( VENDOR_ID, PRODUCT_ID );

if( devices_found.length === 0 ) {
    console.log("no blink(1) devices found");
    process.exit(0);
}

let d = new HID.HID(devices_found[0].path);
d.on('data',function(data){console.log(data)});
d.on('error',function(error){console.log(error)});

setInterval(() => {
    d.write( [0x12, 0xc8, 0x04, 101])
}, 10);

I have tried the node-hid npm and i am able to write the data on it. the status light blinks in circuit but nothing happens to leds.

  • I wonder if the data being written `d.write( [0x12, 0xc8, 0x04, 101])` is correct? Do you have part number or datasheet of the USB LED device that you want to control? Please refer the device manual to find out the correct sequence of data that needs to be sent to get the desired output – Gaurav Pathak Mar 20 '23 at 12:48
  • Yes, it takes the array or buffer data, and I have tried with both but it does not work. – selenagomez Mar 20 '23 at 13:37

0 Answers0