Hi,
I am newbie here. I am trying to get the LED light working with Nodejs. I am using Pi3 with GroviPI kit.
I have tried the python code for Led blinking and it works fine but I want to do the same thing using nodejs but can’t get it to work so far.
I am connecting my led to D4 . I have also tried with Analog 1 but same issue.
Not sure which method I should use in nodejs.
When I try the below code
var GrovePi = require(‘node-grovepi’).GrovePi;
var Commands = GrovePi.commands;
var Board = GrovePi.board;
var LightAnalogSensor = GrovePi.sensors.LightAnalog;
var board = new Board({
debug: true,
onError: function(err) {
console.log(‘Something wrong just happened’);
console.log(err);
},
onInit: function(res) {
if (res) {
console.log('GrovePi Version :: ’ + board.version());
var lightSensor = new LightAnalogSensor(4);
console.log(‘Light Analog Sensor (start watch)’);
lightSensor.on(‘change’, function(res) {
console.log(‘Light onChange value=’ + res);
});
lightSensor.watch();
}
}
});
board.init();
It shows the following
Any help?