So I made a counter in Node-Red and cant figure out hot to reset the counter function when it hits a sertain number, and than to split the payload to 4 different outputs with the number from the counter.
Thanks in advance,
[{"id":"4d070e9f.09b0f","type":"inject","z":"e4d8382f.f4813","name":"trigger at start","topic":"","payload":"0","payloadType":"string","repeat":"","crontab":"","once":true,"x":380,"y":2960,"wires":[["8dee7ece.87a33"]]},{"id":"8dee7ece.87a33","type":"function","z":"e4d8382f.f4813","name":"counter","func":"msg.payload = parseInt(msg.payload) + 1;\nif (msg.payload == 20);\n{\n //set counter back to 1//\n}\nreturn msg;","outputs":"1","noerr":0,"x":641,"y":2962,"wires":[["d488b39a.9c3fa","ca022bfb.4577b8"]]},{"id":"d488b39a.9c3fa","type":"delay","z":"e4d8382f.f4813","name":"trigger ","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":2892,"wires":[["8dee7ece.87a33"]]},{"id":"afd082d7.116a58","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"console":false,"complete":false,"x":1050,"y":2900,"wires":[]},{"id":"ca022bfb.4577b8","type":"function","z":"e4d8382f.f4813","name":"if statement?","func":"if (msg.payload == '1,2') \n {\n return [ msg, null, null, null ];\n } \nelse if (msg.payload == '3,4') \n {\n return [ null, msg, null, null ];\n }\nelse if (msg.payload == '5,6')\n {\n return [ null, null, msg, null ];\n }\nelse()\n{\n return [ null, null, null, msg ];\n}","outputs":4,"noerr":0,"x":850,"y":2960,"wires":[["afd082d7.116a58"],["77f6a89c.1d562"],["4aa41582.1e4da4"],["d70604f.75c3078"]]},{"id":"77f6a89c.1d562","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"console":false,"complete":false,"x":1050,"y":2940,"wires":[]},{"id":"4aa41582.1e4da4","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"console":false,"complete":false,"x":1050,"y":2980,"wires":[]},{"id":"d70604f.75c3078","type":"debug","z":"e4d8382f.f4813","name":"","active":true,"console":false,"complete":false,"x":1050,"y":3020,"wires":[]}]