Metro

This is a subflow that will output 0 and 1 alternatively. You can send it the 'on' or 'off' message to start or stop the output. This can be useful to blink leds for instance.

[{"id":"1ad418f4.e52be7","type":"subflow","name":"Metro","in":[{"x":51,"y":252,"wires":[{"id":"eb5058c2.14afa8"}]}],"out":[{"x":693,"y":194,"wires":[{"id":"717e92af.8e816c","port":0}]}]},{"id":"717e92af.8e816c","type":"trigger","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"250","extend":"false","units":"ms","name":"","x":431,"y":193,"z":"1ad418f4.e52be7","wires":[["36f089f5.c90f76"]]},{"id":"36f089f5.c90f76","type":"function","name":"","func":"if (msg.payload == \"off\")\n\tcontext.state = 0;\nif (msg.payload == \"on\")\n\tcontext.state = 1;\n\nif (context.state == 1)\n{\n\tif (msg.payload == 0)\n\t\treturn msg;\n\telse\n\t\treturn;\n}\nelse\n\treturn;","outputs":1,"x":547,"y":343,"z":"1ad418f4.e52be7","wires":[["c06b5e30.3f94a"]]},{"id":"c06b5e30.3f94a","type":"delay","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":775,"y":344,"z":"1ad418f4.e52be7","wires":[["717e92af.8e816c"]]},{"id":"eb5058c2.14afa8","type":"switch","name":"","property":"payload","rules":[{"t":"eq","v":"on"},{"t":"eq","v":"off"}],"checkall":"true","outputs":2,"x":198,"y":252,"z":"1ad418f4.e52be7","wires":[["36f089f5.c90f76","717e92af.8e816c"],["36f089f5.c90f76"]]}]

Flow Info

Created 10 years ago
Updated 9 years, 4 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • delay (x1)
  • function (x1)
  • switch (x1)
  • trigger (x1)
Other
  • subflow (x1)

Tags

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