Virtual Pin to a GPIO out

Hi I have a prog

For a simple widget you only need param

It is only with combined pins in some widgets like zeRGBa and Joystick in Merge mode that you would use param[0], param[1], etc.

This might be your issue?

Note sure about these commands…

I use PIGPIO… but even for ONOFF it seems the wrong commands to toggle a GPIO pin?

I will have to look it up :slight_smile:


OK, I guess it depends on how you do it… write(value[, callback]) is also an option… in your case perhaps, try…

v0.on('write', function(param) {
	if (param == '1') {
	  lock.write(1);
	} else {
	  lock.write(0);
	}
	console.log('V0',param);
});

Yes It worked THANK you. I was trying param[0] and also function param[0] and it wasnt working. I am only using one virtual in so this is perfect.

I wouldn’t matter how many vPins you used… each independent “function” recognises the value of param as the value of the relevant calling widget.

Oh so it in unnecessary… One more thing to get blynk.notify I added it after :

if (param[0] == ‘1’) {
lock.writeSync(1);
blynk.notify(“Door is Locked”)
} else {
lock.writeSync(0);
blynk.notify(“door is Unlocked”)

however I’m not always getting notifications and also it is interfering with turning on and off the relay. Maybe it is current stall? Is this an efficient way to use blynk.notify?
Thanks

Still have that unnecessary [0] :stuck_out_tongue_winking_eye:

Other issue is that there are time limits for notifications… so simply toggling the button would prevent one or both notifications to not be sent…

Limitations :

- Maximum allowed body length is 120 symbols.
- Only 1 notification per 15 seconds is allowed

Using time and flag checks with additional if then logic will be needed to prevent multiple notifications within those 15 seconds.

Not sure how that is being affected… the two commands (GPIO and notify), are unrelated.

Also, I think you need the ; at the end of these commands