Node that does FIFO function maybe

I have a situation I need some help with. I am building a child's game (not my idea) where they are in a large room. There are four corners with a light in each corner.

The idea is that as the lights light up the children run to that corner of the room. At any given time there are only two lights on. The one where they are and the one they are running to. The lights start in a random corner and go in a random sequence. That part I can manage. My problem is turning off the lights in the correct sequence.

The lights turn on in any order and must be turned off in the same sequence. This seems like a FIFO problem but I can't wrap my head this.

When should it switch off?

If you want it to turn off a fixed time after you turn on the next one, then construct the message to turn off the original light at the same time as you turn the next one on, but send it through a delay node with the appropriate delay time configured.

1 Like

The light will probably be on around 15 seconds, but how do I get around the random problem

Did I understand the logic correctly ?

[{"id":"3e834ab61b79a208","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":1,"width":"2","height":"2","passthru":false,"label":"TL","tooltip":"","color":"","bgcolor":"{{bctl}}","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":290,"y":510,"wires":[[]]},{"id":"47b73d1735d2ac7b","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":3,"width":"2","height":"2","passthru":false,"label":"TR","tooltip":"","color":"","bgcolor":"{{bctr}}","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":580,"y":510,"wires":[[]]},{"id":"3c8537f1d59365ba","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":7,"width":"2","height":"2","passthru":false,"label":"BL","tooltip":"","color":"","bgcolor":"{{bcbl}}","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":290,"y":630,"wires":[[]]},{"id":"6648e231c89fe4d1","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":9,"width":"2","height":"2","passthru":false,"label":"BR","tooltip":"","color":"","bgcolor":"{{bcbr}}","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":580,"y":630,"wires":[[]]},{"id":"7c87ec6c4ecdfa52","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":2,"width":"6","height":"2","passthru":false,"label":"N","tooltip":"","color":"grey","bgcolor":"grey","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":410,"y":510,"wires":[[]]},{"id":"fe89ec50c33871a9","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":8,"width":"6","height":"2","passthru":false,"label":"S","tooltip":"","color":"grey","bgcolor":"grey","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":410,"y":630,"wires":[[]]},{"id":"d56f381a7ac49b02","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":6,"width":"2","height":"6","passthru":false,"label":"E","tooltip":"","color":"grey","bgcolor":"grey","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":580,"y":570,"wires":[[]]},{"id":"3e95279357eee624","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":4,"width":"2","height":"6","passthru":false,"label":"W","tooltip":"","color":"grey","bgcolor":"grey","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":290,"y":570,"wires":[[]]},{"id":"10de5219093a65b7","type":"ui_button","z":"242715e96c9f251a","name":"","group":"6ab22327.a2f71c","order":5,"width":"6","height":"6","passthru":true,"label":"Trigger","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"num","topic":"topic","topicType":"msg","x":420,"y":570,"wires":[["3a20266b6c2387e1"]]},{"id":"3a20266b6c2387e1","type":"random","z":"242715e96c9f251a","name":"","low":1,"high":"4","inte":"true","property":"payload","x":270,"y":870,"wires":[["381c018335c75ecc"]]},{"id":"5b6ff75d9d693571","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bctl","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":630,"wires":[["89c65e40273f9923","5049f60bedcc0185"]]},{"id":"b040e3edc97ab2dc","type":"switch","z":"242715e96c9f251a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"}],"checkall":"true","repair":false,"outputs":4,"x":770,"y":720,"wires":[["5b6ff75d9d693571"],["73a769226ef7b7f2"],["00efc15641cd553a"],["e2039c1d5c3e9a16"]]},{"id":"5049f60bedcc0185","type":"link out","z":"242715e96c9f251a","name":"link out 146","mode":"link","links":["3986da9c67004328","75c3f44e5015ea2a","6fb0ab6603a2ef68","097b8a6e09af8386"],"x":1365,"y":450,"wires":[]},{"id":"3986da9c67004328","type":"link in","z":"242715e96c9f251a","name":"link in 176","links":["5049f60bedcc0185"],"x":495,"y":510,"wires":[["47b73d1735d2ac7b"]]},{"id":"097b8a6e09af8386","type":"link in","z":"242715e96c9f251a","name":"link in 177","links":["5049f60bedcc0185"],"x":495,"y":630,"wires":[["6648e231c89fe4d1"]]},{"id":"6fb0ab6603a2ef68","type":"link in","z":"242715e96c9f251a","name":"link in 178","links":["5049f60bedcc0185"],"x":195,"y":630,"wires":[["3c8537f1d59365ba"]]},{"id":"75c3f44e5015ea2a","type":"link in","z":"242715e96c9f251a","name":"link in 179","links":["5049f60bedcc0185"],"x":195,"y":510,"wires":[["3e834ab61b79a208"]]},{"id":"73a769226ef7b7f2","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bctr","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":690,"wires":[["c0419aa71c0627a1","5049f60bedcc0185"]]},{"id":"00efc15641cd553a","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bcbl","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":750,"wires":[["11a56f332f29d1d2","5049f60bedcc0185"]]},{"id":"e2039c1d5c3e9a16","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bcbr","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":810,"wires":[["b7add8386c188d2d","5049f60bedcc0185"]]},{"id":"76f53b528df87113","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"number","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":870,"wires":[["b0b7f624c10fd7b4"]]},{"id":"381c018335c75ecc","type":"switch","z":"242715e96c9f251a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"number","vt":"flow"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":440,"y":870,"wires":[["10de5219093a65b7"],["76f53b528df87113"]]},{"id":"b0b7f624c10fd7b4","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"number","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":870,"wires":[["b040e3edc97ab2dc"]]},{"id":"a74cbe1de0110245","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bctr","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bcbl","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bcbr","pt":"msg","to":"grey","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":630,"wires":[["5049f60bedcc0185"]]},{"id":"89c65e40273f9923","type":"delay","z":"242715e96c9f251a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1110,"y":630,"wires":[["a74cbe1de0110245"]]},{"id":"d7075693ba846719","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bctl","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bcbl","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bcbr","pt":"msg","to":"grey","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":690,"wires":[["5049f60bedcc0185"]]},{"id":"c0419aa71c0627a1","type":"delay","z":"242715e96c9f251a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1110,"y":690,"wires":[["d7075693ba846719"]]},{"id":"4dcad3a1f0137b79","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bctl","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bctr","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bcbr","pt":"msg","to":"grey","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":750,"wires":[["5049f60bedcc0185"]]},{"id":"11a56f332f29d1d2","type":"delay","z":"242715e96c9f251a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1110,"y":750,"wires":[["4dcad3a1f0137b79"]]},{"id":"7d52fd87c9e26197","type":"change","z":"242715e96c9f251a","name":"","rules":[{"t":"set","p":"bctl","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bctr","pt":"msg","to":"grey","tot":"str"},{"t":"set","p":"bcbl","pt":"msg","to":"grey","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":810,"wires":[["5049f60bedcc0185"]]},{"id":"b7add8386c188d2d","type":"delay","z":"242715e96c9f251a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1110,"y":810,"wires":[["7d52fd87c9e26197"]]},{"id":"6ab22327.a2f71c","type":"ui_group","name":"HOME","tab":"6d306f92.ccc54","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"6d306f92.ccc54","type":"ui_tab","name":"TEST","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

new

2 Likes

yep you got it exactly right! thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.