Blinking a LED on Raspberry PI

This flow allows to blink a LED on Raspberry PI until you want to stop it.

[{"id":"740a99d2.b07d1","type":"function","z":"b71ac87f.d81188","name":"startBlink","func":"var BLINKDELAY = 250;\n\nvar light = true;\n\n\nvar blinker = setInterval(blink, BLINKDELAY);\n\nglobal.set(\"blinker\", blinker);\n\nfunction blink () {\n    \n    if (light) {\n        msg.payload = 1;\n        light = false;\n    }\n    \n    else {\n        msg.payload = 0;\n        light = true;\n    }\n    \n    node.send(msg);\n}\n\n\nreturn;","outputs":1,"noerr":0,"x":282,"y":153,"wires":[["41b167bc.bbffc"]]},{"id":"73f5f278.0231bc","type":"inject","z":"b71ac87f.d81188","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":126,"y":153,"wires":[["740a99d2.b07d1"]]},{"id":"41b167bc.bbffc","type":"rpi-gpio out","z":"b71ac87f.d81188","name":"","pin":"15","set":"","level":"0","out":"out","x":471,"y":153,"wires":[]},{"id":"cc1b11b1.bebb28","type":"function","z":"b71ac87f.d81188","name":"stopBlink","func":"clearInterval(global.get(\"blinker\"));\n\nmsg.payload = 0;\n\nreturn msg;","outputs":1,"noerr":0,"x":288,"y":225,"wires":[["41b167bc.bbffc"]]},{"id":"5db82a6c.1b547c","type":"inject","z":"b71ac87f.d81188","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":123,"y":226,"wires":[["cc1b11b1.bebb28"]]}]

Flow Info

Created 8 years, 1 month ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • function (x2)
  • inject (x2)
Other

Tags

  • RaspberryPi
  • Blinking
  • Blink
  • LED
  • Stop
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option