I have 2 problems:
I want to have a virtual lamp, when gpio 21 is high and i want a virtual lamp when gpio 21 is low (on v2 and v3). I really dont know what i did wrong but nothing works.
SyntaxError: Invalid or unexpected token
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions…js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:387:7)
at startup (bootstrap_node.js:153:9)
This would be a simple NodeJS example of repeating back what you type into your terminal widget with Time and Date added on.
var term = new blynk.WidgetTerminal(vPin); // Setup Terminal Widget. Use number only, no V
// Repeat terminal input
term.on('write', function(data) {
term.write('You wrote:' + data + " @ " + new Date().toTimeString() + " " + new Date().toDateString() + '\n');
});
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
There is no “full code” to give… your setup and situation is totally different from mine.
All I could do it write it all for you from scratch… and no, I am not going to do that I have a difficult enough time writing my own code.
You need to learn how to do some basic programming with NodeJS if you want to use it for Blynk. All the tools are here, and some Google searching would probably go a long way as well.