Hi. Im new to programing so i need help to make the scrip work right. Below is my basic script to trigger the relays.
Im having problems because the script toggles the relay on startup so i would like to implement the function Blynk.syncAll
so that the last command is always set on startup. The second thing i would like to add is the code to set the duration( in sec ) for the command when pressing the button.
var Blynk = require(‘blynk-library’);
var Gpio = require(‘onoff’).Gpio;
var led = new Gpio(11, ‘out’);
var AUTH = ‘...........’;
var blynk = new Blynk.Blynk(AUTH);
var v0 = new blynk.VirtualPin(0);
v0.on(‘write’, function(param) {
if (param[0] == ‘1’) {
led.writeSync(1);
} else {
led.writeSync(0);
}
console.log(‘Open’, param[0]);
});