Need help with NodeJS

Read through all those NodeJS examples, in the link above, to get a better idea of the various commands and syntax… Blynk NodeJS requires a bit more learning and effort on your part

The GPIO state detection will depend on the GPIO library you uses, here are a few. I currently use pigpio

pigpio - npm

You define your GPIO pin something like this

const Gpio = require('pigpio').Gpio;
const Pin21 = new Gpio(21, {mode: Gpio.INPUT, pullUpDown: Gpio.PUD_DOWN, edge: Gpio.EITHER_EDGE});

Detect the GPIO state and control your vPin like this

Pin21.on('interrupt', function (value) {
    blynk.virtualWrite(2, value);  // send GPIO state to vPin 2
});

I also have a small NodeJS example for the Joystick widget that controls servos… so hopefully you can get some further syntax ideas from it as well.

1 Like