How to flash a LED?

Does someone now how i can flash my ligt on 1hz. I want to do it in a function.

this is what i have for color, now i want to flash it on 1hz??
image

Did you search the forum/flows ? Did you read the documentation ?

To flash the LED, you will have to send it a message every second to turn it on or off.

How long do you want to flash it for? I assume at some point you'll want it to stop flashing? How do you control that?

image

So i use a numeric: 1 is led1 blue / 2 is led1 red / 3 is led1 green /.... 8 colors long.
than 9 needs to be led1 blue but flashing at 1hz the holle time it may only go out if i change the numeric.

I searched some thongs about blinking a led and found some information .
i have a flow when payload 9 is set by numeric led 1 flash every 2 sec. But i want it to go out when i change from payload .

this is info that i found : [{"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"]]}]

this is my flow : [{"id":"2fac170c.3341f8","type":"ui_numeric","z":"2df27252.fc52ce","name":"","label":"LED 2","group":"95c63973.5f2fe8","order":1,"width":0,"height":0,"passthru":true,"topic":"","format":"{{value}}","min":"0","max":"28","step":1,"x":728,"y":2320,"wires":[["fd5eb88f.be0ed8"]]},{"id":"fd5eb88f.be0ed8","type":"function","z":"2df27252.fc52ce","name":"werkt","func":"if (msg.payload === 9) \nreturn msg;\n ","outputs":1,"noerr":0,"x":870.0001068115234,"y":2317.000120162964,"wires":[["86aca0a9.36203"]]},{"id":"86aca0a9.36203","type":"function","z":"2df27252.fc52ce","name":"WERKT","func":"\nvar BLINKDELAY = 2000;\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+','+ 0 +','+ 0 +','+ 255;\n light = false;\n }\n \n else {\n msg.payload = 1+','+ 0 +','+ 0 +','+ 0;\n light = true;\n }\n \n node.send(msg);\n}\n\n\nreturn;","outputs":1,"noerr":0,"x":1022.000114440918,"y":2318.000120162964,"wires":[]},{"id":"95c63973.5f2fe8","type":"ui_group","z":"","name":"TEST","tab":"62115615.d43ac8","order":5,"disp":true,"width":"6","collapse":false},{"id":"62115615.d43ac8","type":"ui_tab","z":"","name":"ProTrac demo case","icon":"dashboard","order":2}]

Your flows are not importable. Please read this thread and edit your previous post to fix the flows.

My version of blinking LEDs... Might be overkill for what you want...

[{"id":"660af883.f2433","type":"inject","z":"21881b08.3ed344","name":"Suspend","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"str","x":100,"y":480,"wires":[["29bb29e4.f6f4d6"]]},{"id":"5713ab96.050cf4","type":"inject","z":"21881b08.3ed344","name":"Resume","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":100,"y":520,"wires":[["ef9834bc.30ad2"]]},{"id":"29bb29e4.f6f4d6","type":"ui_button","z":"21881b08.3ed344","name":"Pause","group":"c6d9a10c.fc53e","order":4,"width":0,"height":0,"passthru":false,"label":"Pause","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"Control","x":270,"y":460,"wires":[["dfc54c0e.7deeb8","588e5973.057d7","a55191a1.b8c1e8","1bd8cd46.5dd383"]]},{"id":"ef9834bc.30ad2","type":"ui_button","z":"21881b08.3ed344","name":"Resume","group":"c6d9a10c.fc53e","order":5,"width":0,"height":0,"passthru":false,"label":"Resume","tooltip":"","color":"","bgcolor":"","icon":"","payload":"0","payloadType":"str","topic":"Control","x":280,"y":540,"wires":[["131daeae.bdbc79","b70099e.100fae8","a55191a1.b8c1e8"]]},{"id":"afedccc6.d2b448","type":"gate","z":"21881b08.3ed344","name":"Pause Or Resume!","controlTopic":"Control","defaultState":"open","openCmd":"0","closeCmd":"1","toggleCmd":"","defaultCmd":"","persist":true,"x":1090,"y":80,"wires":[["8e6f5d59.f4e95","d5bd5703.27acd8"]]},{"id":"dfc54c0e.7deeb8","type":"change","z":"21881b08.3ed344","name":"Disable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":380,"wires":[["29bb29e4.f6f4d6"]]},{"id":"b70099e.100fae8","type":"change","z":"21881b08.3ed344","name":"Enable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":540,"wires":[["29bb29e4.f6f4d6","39b3b4fa.202974"]]},{"id":"131daeae.bdbc79","type":"change","z":"21881b08.3ed344","name":"Disable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":620,"wires":[["ef9834bc.30ad2"]]},{"id":"588e5973.057d7","type":"change","z":"21881b08.3ed344","name":"Enable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":460,"wires":[["ef9834bc.30ad2","39b3b4fa.202974"]]},{"id":"7d1297f8.056aa8","type":"mqtt in","z":"21881b08.3ed344","name":"Pi4ModelB0 (/+/diode/control)","topic":"/+/diode/control","qos":"2","datatype":"auto","broker":"1afc674b.a8ebe9","x":160,"y":100,"wires":[["267c8d57.28f232"]]},{"id":"6d0e5642.42a1a8","type":"ui_switch","z":"21881b08.3ed344","name":"","label":"Red","tooltip":"","group":"c6d9a10c.fc53e","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"Red","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1050,"y":500,"wires":[["f8d8b557.41934","2fe26cf2.d7ab2c","bdc02379.c2c2e"]]},{"id":"18421109.c4da1f","type":"ui_switch","z":"21881b08.3ed344","name":"","label":"Blue","tooltip":"","group":"c6d9a10c.fc53e","order":3,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"Blue","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1050,"y":620,"wires":[["f8d8b557.41934","2fe26cf2.d7ab2c","bdc02379.c2c2e"]]},{"id":"4e25a01f.10ad6","type":"ui_switch","z":"21881b08.3ed344","name":"","label":"Green","tooltip":"","group":"c6d9a10c.fc53e","order":2,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"Green","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1050,"y":560,"wires":[["f8d8b557.41934","2fe26cf2.d7ab2c","bdc02379.c2c2e"]]},{"id":"f8d8b557.41934","type":"switch","z":"21881b08.3ed344","name":"On Or Off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1270,"y":500,"wires":[["a0eafa16.6c6bc"],["c01cf458.4f7508"]]},{"id":"a0eafa16.6c6bc","type":"link out","z":"21881b08.3ed344","name":"On","links":["184a9040.1b8b28"],"x":1395,"y":460,"wires":[]},{"id":"c01cf458.4f7508","type":"link out","z":"21881b08.3ed344","name":"Off","links":["ad438d75.e910a"],"x":1395,"y":540,"wires":[]},{"id":"184a9040.1b8b28","type":"link in","z":"21881b08.3ed344","name":"On","links":["a0eafa16.6c6bc"],"x":635,"y":480,"wires":[["52908edd.9e989"]]},{"id":"ad438d75.e910a","type":"link in","z":"21881b08.3ed344","name":"Off","links":["c01cf458.4f7508"],"x":635,"y":560,"wires":[["b7927ed5.6b92a8"]]},{"id":"b2f1e18d.5ac0d8","type":"comment","z":"21881b08.3ed344","name":"On","info":"","x":670,"y":440,"wires":[]},{"id":"b3222a5f.c54b48","type":"comment","z":"21881b08.3ed344","name":"Off","info":"","x":670,"y":520,"wires":[]},{"id":"b7927ed5.6b92a8","type":"change","z":"21881b08.3ed344","name":"Enable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":560,"wires":[["18421109.c4da1f","4e25a01f.10ad6","6d0e5642.42a1a8"]]},{"id":"52908edd.9e989","type":"function","z":"21881b08.3ed344","name":"Enable/Disable","func":"const disabledMsg = {payload: false, enabled: false}\n\nlet msgs\n\nswitch(msg.topic) {\n\n  case \"Red\":\n    msgs = [msg, disabledMsg, disabledMsg]\n    break;\n\n  case \"Green\":\n    msgs = [disabledMsg, msg, disabledMsg]\n    break;\n\n  default:\n    msgs = [disabledMsg, disabledMsg, msg]\n    break;\n} \n\nreturn msgs;","outputs":3,"noerr":0,"x":820,"y":480,"wires":[["6d0e5642.42a1a8"],["4e25a01f.10ad6"],["18421109.c4da1f"]]},{"id":"25d0475e.1a0228","type":"comment","z":"21881b08.3ed344","name":"On","info":"","x":1430,"y":420,"wires":[]},{"id":"4501e2a2.1e35ac","type":"comment","z":"21881b08.3ed344","name":"Off","info":"","x":1430,"y":500,"wires":[]},{"id":"ede7fefb.355ff8","type":"inject","z":"21881b08.3ed344","name":"Red On","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Red","payload":"1","payloadType":"num","x":930,"y":200,"wires":[["bcf42efe.c92e88"]]},{"id":"99872b19.c977","type":"inject","z":"21881b08.3ed344","name":"Blue On","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Blue","payload":"1","payloadType":"num","x":940,"y":360,"wires":[["bcf42efe.c92e88"]]},{"id":"324005aa.a08802","type":"inject","z":"21881b08.3ed344","name":"Red Off","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Red","payload":"0","payloadType":"num","x":930,"y":240,"wires":[["bcf42efe.c92e88"]]},{"id":"2d128b7c.dc16ac","type":"inject","z":"21881b08.3ed344","name":"Blue Off","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Blue","payload":"0","payloadType":"num","x":940,"y":400,"wires":[["bcf42efe.c92e88"]]},{"id":"4f60b09b.e33f48","type":"inject","z":"21881b08.3ed344","name":"Green On","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Green","payload":"1","payloadType":"num","x":940,"y":280,"wires":[["bcf42efe.c92e88"]]},{"id":"e7eaa862.88ed1","type":"inject","z":"21881b08.3ed344","name":"Green Off","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Green","payload":"0","payloadType":"num","x":940,"y":320,"wires":[["bcf42efe.c92e88"]]},{"id":"8e6f5d59.f4e95","type":"debug","z":"21881b08.3ed344","name":"Message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":40,"wires":[]},{"id":"771d4087.a3ec18","type":"change","z":"21881b08.3ed344","name":"Disable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":640,"wires":[["6d0e5642.42a1a8","4e25a01f.10ad6","18421109.c4da1f"]]},{"id":"a55191a1.b8c1e8","type":"switch","z":"21881b08.3ed344","name":"Pause Or Resume?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":480,"y":600,"wires":[["b7927ed5.6b92a8"],["771d4087.a3ec18"]]},{"id":"f4035760.b654e","type":"pi-gpiod out","z":"21881b08.3ed344","name":"Board 36 GPIO 16 Wire Red","host":"localhost","port":8888,"pin":"16","set":true,"level":"0","out":"out","sermin":"1000","sermax":"2000","x":1680,"y":80,"wires":[]},{"id":"a19b7be1.05ed9","type":"pi-gpiod out","z":"21881b08.3ed344","name":"Board 38 GPIO 20 Wire Green","host":"localhost","port":8888,"pin":"20","set":true,"level":"0","out":"out","sermin":"1000","sermax":"2000","x":1730,"y":120,"wires":[]},{"id":"3c4da703.b52958","type":"pi-gpiod out","z":"21881b08.3ed344","name":"Board 40 GPIO 21 Wire Blue","host":"localhost","port":8888,"pin":"21","set":true,"level":"0","out":"out","sermin":"1000","sermax":"2000","x":1760,"y":160,"wires":[]},{"id":"2a82da7b.c02456","type":"comment","z":"21881b08.3ed344","name":"Ground (GND) GPIO 34 Wire Brown Or Gray","info":"","x":1850,"y":200,"wires":[]},{"id":"6dea7870.25ccb8","type":"switch","z":"21881b08.3ed344","name":"Topic","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"Red","vt":"str"},{"t":"eq","v":"Green","vt":"str"},{"t":"eq","v":"Blue","vt":"str"},{"t":"eq","v":"None","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":1430,"y":120,"wires":[["f4035760.b654e"],["a19b7be1.05ed9"],["3c4da703.b52958"],["f4035760.b654e","a19b7be1.05ed9","3c4da703.b52958"]]},{"id":"e6eae89b.628398","type":"delay","z":"21881b08.3ed344","name":"Queue (1s)","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":890,"y":80,"wires":[["afedccc6.d2b448"]]},{"id":"2fe26cf2.d7ab2c","type":"debug","z":"21881b08.3ed344","name":"Message","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1260,"y":560,"wires":[]},{"id":"d5bd5703.27acd8","type":"function","z":"21881b08.3ed344","name":"Numeric","func":"msg.payload=Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1280,"y":80,"wires":[["6dea7870.25ccb8"]]},{"id":"1bd8cd46.5dd383","type":"change","z":"21881b08.3ed344","name":"None","rules":[{"t":"set","p":"topic","pt":"msg","to":"None","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":400,"wires":[["5937ad61.78b66c"]]},{"id":"c7c0234f.bde27","type":"mqtt out","z":"21881b08.3ed344","name":"Pi4ModelB0 (/<Host>/diode/control)","topic":"","qos":"","retain":"","broker":"1afc674b.a8ebe9","x":660,"y":720,"wires":[]},{"id":"86a4e7bf.360f18","type":"inject","z":"21881b08.3ed344","name":"Flash Red (5x)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"Red\":1},{\"Red\":0},{\"Red\":1},{\"Red\":0},{\"Red\":1},{\"Red\":0},{\"Red\":1},{\"Red\":0},{\"Red\":1},{\"Red\":0}]","payloadType":"json","x":120,"y":720,"wires":[["c6b1f391.a82398"]]},{"id":"267c8d57.28f232","type":"json","z":"21881b08.3ed344","name":"","property":"payload","action":"obj","pretty":false,"x":370,"y":80,"wires":[["7f0648d7.335b88"]]},{"id":"7f0648d7.335b88","type":"split","z":"21881b08.3ed344","name":"Split Array","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":530,"y":80,"wires":[["ac72da6c.0d49f"]]},{"id":"ac72da6c.0d49f","type":"split","z":"21881b08.3ed344","name":"Split Payload","splt":":","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":710,"y":80,"wires":[["e6eae89b.628398"]]},{"id":"c6b1f391.a82398","type":"function","z":"21881b08.3ed344","name":"Topic (/<Host>/diode/control)","func":"var theHost = global.get('os').hostname().split('.')[0];\n\nmsg.topic=`/${theHost}/diode/control`;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":720,"wires":[["c7c0234f.bde27"]]},{"id":"54ace069.1860b8","type":"cronplus","z":"21881b08.3ed344","name":"Automatic Flash  Blue (1m)","outputField":"payload","timeZone":"","persistDynamic":true,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"Flash","topic":"Fash","payloadType":"str","payload":"[{\"Blue\":1},{\"Blue\":0},{\"Blue\":1},{\"Blue\":0},{\"Blue\":1},{\"Blue\":0},{\"Blue\":1},{\"Blue\":0},{\"Blue\":1},{\"Blue\":0}]","expressionType":"cron","expression":"0 */1 * * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":160,"y":40,"wires":[["267c8d57.28f232"]]},{"id":"5937ad61.78b66c","type":"link out","z":"21881b08.3ed344","name":"","links":["3ed1e198.fd55ce"],"x":555,"y":400,"wires":[]},{"id":"3ed1e198.fd55ce","type":"link in","z":"21881b08.3ed344","name":"","links":["5937ad61.78b66c"],"x":1315,"y":120,"wires":[["6dea7870.25ccb8"]]},{"id":"b5a0c894.43373","type":"link in","z":"21881b08.3ed344","name":"","links":["39b3b4fa.202974"],"x":935,"y":120,"wires":[["afedccc6.d2b448"]]},{"id":"39b3b4fa.202974","type":"link out","z":"21881b08.3ed344","name":"","links":["b5a0c894.43373"],"x":555,"y":500,"wires":[]},{"id":"bcf42efe.c92e88","type":"link out","z":"21881b08.3ed344","name":"","links":["fcda7554.4f1d9"],"x":1075,"y":300,"wires":[]},{"id":"fcda7554.4f1d9","type":"link in","z":"21881b08.3ed344","name":"","links":["bcf42efe.c92e88"],"x":1135,"y":460,"wires":[["f8d8b557.41934"]]},{"id":"bdc02379.c2c2e","type":"link out","z":"21881b08.3ed344","name":"","links":["97bcccf1.612778"],"x":1215,"y":620,"wires":[]},{"id":"97bcccf1.612778","type":"link in","z":"21881b08.3ed344","name":"","links":["bdc02379.c2c2e"],"x":755,"y":120,"wires":[["e6eae89b.628398"]]},{"id":"c6d9a10c.fc53e","type":"ui_group","z":"","name":"Diodes 2.3.5","tab":"db9a95e7.fce2c","order":5,"disp":true,"width":3,"collapse":true},{"id":"1afc674b.a8ebe9","type":"mqtt-broker","z":"","name":"Pi4ModelB0","broker":"pi4modelb0.dachshund-digital.org","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"db9a95e7.fce2c","type":"ui_tab","z":"","name":"Control","icon":"dashboard","order":7,"disabled":false,"hidden":false}]

I use a simple RGB breakout LED board, so 3 GPIO pins, one per color. I can turn on/off each locally or remotely (via MQTT). And, by default, the blue element flashes for about 10 seconds every 60 seconds, as an 'I am live' indicator.