BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Raspberry Pi program bug

nodejs
#1

Hi
I am programming a raspberry Pi but there is a bug in my program but I can’t fix it. The bug is that when I press V2 in the app the relais works but I also get a notification. Could someone please take a look at my program and maybe you can see the fault.
Thanks in advance!

var Blynk = require('/usr/local/lib/node_modules/blynk-library');
var AUTH = 'b6216e4b56964600ba05xxxxxx';
var blynk = new Blynk.Blynk(AUTH);

const Gpio = require('onoff').Gpio;				
const schakelaar = new Gpio(2, 'in', 'both');		//schakelaar deksel
const relais = new Gpio(7, 'out');					//relais solenoid
const IR = new Gpio(3, 'in', 'both');				//IR sensor
const bel = new Gpio(6, 'in', 'both');				//Drukknop bellen
const LED = new blynk.VirtualPin(5);
const EN = new Gpio(5, 'out');

var v2 = new blynk.VirtualPin(2);
	
	EN .writeSync(1)
	
	schakelaar.watch((err, value) => {
		if (err) {
		throw err;
		}

		if (value == 0) {blynk.notify("open");}
		console.log('value is:', value);
		});
		process.on('SIGINT', () => {
		schakelaar.unexport();
		}); 

	v2.on('write', function() {
		if(relais.readSync() == 0) {
				relais.writeSync(1);
		}
		else {
				relais.writeSync(0);
		}	
		});

	bel.watch((err, value) => {
		if (err) {
		throw err;
		}

		if (value == 0) {blynk.notify("test");}
		console.log('value is:', value);
		});
		process.on('SIGINT', () => {
		bel.unexport();
		}); 

	IR.watch((err, value) => {
		if (err) {
		throw err;
		}

		if (value == 0) {blynk.notify("geplaatst");}
		console.log('value is:', value);
		});
		process.on('SIGINT', () => {
		IR.unexport();
		}); 


	IR.watch((err, value) => {
		if (value == 0) {blynk.virtualWrite(5, 255);
		}
		else {
				blynk.virtualWrite(5, 0);
		}	
		});
0 Likes