Node.js Syntax Explanation

var Blynk = require(‘blynk-library’);

var AUTH = ‘YourAuthToken’;

var blynk = new Blynk.Blynk(AUTH);

var v1 = new blynk.VirtualPin(1);
var v9 = new blynk.VirtualPin(9);

v1.on(‘write’, function(param) {
console.log(‘V1:’, param[0]);

v9.on(‘read’, function() {
v9.write(new Date().getSeconds());

i have Raspberry pi 3 then try this code and run succesfully for controlling the LED, but i still confuse about v1 and v9 function, how it works ?
because in Blynk apps i’m just select GPIO pin 27 for my button then the led was work normally…

Please someone tell me about that Thank you

The v1 and v9 are virtual pin functions…

V1 looks to be for a Slider or Button Widget (you have to set this up in the App) and it will display the value of such, as you move or press it, in the RPi console display (AKA the terminal window from which you started the script)

V9 is for a Display widget (you have to set this up in the App as well and set it for a reading rate - set for 1 second)… which means the widget calls the function every second and the function send back the RPi’s current clock seconds (from 0-60)

That is what I call direct pin manipulation and is fine for simple tasks, but writing code and functions gives much more control.

I have some NodeJS examples here