# Multiple physical buttons GPIO - only one push button at a time + RGB strip and relays sequence with variable delays

**URL:** <https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722>\
**Category:** General\
**Created:** [28 October 2022 10:04 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722 "2022-10-28T10:04:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aquapark\_lodz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aquapark_lodz/32/69828_2.png) [@aquapark\_lodz](https://discourse.nodered.org/u/aquapark_lodz)\
**Post date:** [28 October 2022 10:04 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/1 "2022-10-28T10:04:21Z")

</div>

Hi,  
My project is simple for now:  
I have 3 physical buttons which I connected to my relay board. Each button is connected to a separate relay and what node can I use to prevent simultaneous pressing of two or three buttons at the same time. I am looking the whole web to do so but there are all topics with one button or multiple presses on a single button.  
I want to make the whole sequences for each buttons with relays but for know I must know how to push only one button at the same time.  
I think the function node will be helpful for that but I don't know javascript language.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a684b4511e722c3426f3b9cecf280e54e275f64.png)

I will be very grateful for your help

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:12 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/2 "2022-10-28T10:12:01Z")

</div>

I'm guessing the physical buttons "lock" when pressed.  
So you press it, and it stays in a condition.  
You press it again and the condition toggles.

I don't know if that will be easy.

You may need to go to press buttons (momentary press, non-locking).

Then you will have to make a bit of _code_.  
Each button sets a `topic` for its message.

All 3 messages are sent into a _node_ (`function`) and a lot of work happens in there.

Sorry, it is 21:11 local time and I woke up this morning at 05:45 local.  
(Gotta love insomnia.) ☹

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2022 10:12 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/3 "2022-10-28T10:12:26Z")

</div>

Here is a sample of how you could do it with the `trigger` node

 ![Screen Shot 2022-10-28 at 6.14.21 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f0f9e7e4947fc9304884036421c3f97f568056c9.png)

```auto
[{"id":"ed9404a32493f348","type":"inject","z":"dd25585074ececfb","name":"button 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 1","payloadType":"str","x":220,"y":80,"wires":[["fa397cd50e53da64"]]},{"id":"5d44870ef3d8fcc9","type":"debug","z":"dd25585074ececfb","name":"relay 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":80,"wires":[]},{"id":"542ec01399d74cdf","type":"inject","z":"dd25585074ececfb","name":"button 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 2","payloadType":"str","x":220,"y":140,"wires":[["fa397cd50e53da64"]]},{"id":"f6aac4011f02294d","type":"inject","z":"dd25585074ececfb","name":"button 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 3","payloadType":"str","x":220,"y":200,"wires":[["fa397cd50e53da64"]]},{"id":"504994e68a6fd402","type":"debug","z":"dd25585074ececfb","name":"relay 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":140,"wires":[]},{"id":"8ab0c75a9b116c02","type":"debug","z":"dd25585074ececfb","name":"relay 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":200,"wires":[]},{"id":"4974e765e65fc82b","type":"switch","z":"dd25585074ececfb","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"button 1","vt":"str"},{"t":"eq","v":"button 2","vt":"str"},{"t":"eq","v":"button 3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":630,"y":140,"wires":[["5d44870ef3d8fcc9"],["504994e68a6fd402"],["8ab0c75a9b116c02"]]},{"id":"fa397cd50e53da64","type":"trigger","z":"dd25585074ececfb","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":420,"y":140,"wires":[["4974e765e65fc82b"]]},{"id":"7b5fb12647fcae7d","type":"inject","z":"dd25585074ececfb","name":"RESET","props":[{"p":"reset","v":"reset","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":300,"wires":[["fa397cd50e53da64"]]}]

```

---

<div class="post-metadata">

**Author:** ![aquapark\_lodz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aquapark_lodz/32/69828_2.png) [@aquapark\_lodz](https://discourse.nodered.org/u/aquapark_lodz)\
**Post date:** [28 October 2022 10:17 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/4 "2022-10-28T10:17:34Z")

</div>

Thank you Trying\_to\_learn and zenofmud.  
I have Raspberry Pi4 and I want to use GPIO 3 physical push button to steer some sequences with relays. Each sequence will take 120 seconds. Now when I push button it doesn't "lock" when pressed is momentary.  
So with trigger node I must prevent other buttons to activate other sequences for 120 seconds

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:19 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/5 "2022-10-28T10:19:59Z")

</div>

@zenofmud has a good starting point.

I am new to NR 3.x

I don't want to step on his work, but I would do it slightly different.  
Rather than the 4'th `inject`: a `delay` node set to `120` seconds and it sends the `reset` message.

Something like this:

```auto
[{"id":"fa397cd50e53da64","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":2900,"y":3950,"wires":[["4974e765e65fc82b","5208e2ef16afd9b6"]]},{"id":"ed9404a32493f348","type":"inject","z":"0918ee609bf69fc7","name":"button 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 1","payloadType":"str","x":2700,"y":3890,"wires":[["fa397cd50e53da64"]]},{"id":"542ec01399d74cdf","type":"inject","z":"0918ee609bf69fc7","name":"button 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 2","payloadType":"str","x":2700,"y":3950,"wires":[["fa397cd50e53da64"]]},{"id":"f6aac4011f02294d","type":"inject","z":"0918ee609bf69fc7","name":"button 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 3","payloadType":"str","x":2700,"y":4010,"wires":[["fa397cd50e53da64"]]},{"id":"90312086218313de","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3070,"y":4060,"wires":[["fa397cd50e53da64"]]},{"id":"4974e765e65fc82b","type":"switch","z":"0918ee609bf69fc7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"button 1","vt":"str"},{"t":"eq","v":"button 2","vt":"str"},{"t":"eq","v":"button 3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":3110,"y":3950,"wires":[["5d44870ef3d8fcc9"],["504994e68a6fd402"],["8ab0c75a9b116c02"]]},{"id":"5208e2ef16afd9b6","type":"delay","z":"0918ee609bf69fc7","name":"","pauseType":"delay","timeout":"120","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":3060,"y":4020,"wires":[["90312086218313de"]]},{"id":"5d44870ef3d8fcc9","type":"debug","z":"0918ee609bf69fc7","name":"relay 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3350,"y":3890,"wires":[]},{"id":"504994e68a6fd402","type":"debug","z":"0918ee609bf69fc7","name":"relay 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3350,"y":3950,"wires":[]},{"id":"8ab0c75a9b116c02","type":"debug","z":"0918ee609bf69fc7","name":"relay 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3350,"y":4010,"wires":[]}]

```

No offense @zenofmud

---

<div class="post-metadata">

**Author:** ![aquapark\_lodz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aquapark_lodz/32/69828_2.png) [@aquapark\_lodz](https://discourse.nodered.org/u/aquapark_lodz)\
**Post date:** [28 October 2022 10:22 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/6 "2022-10-28T10:22:05Z")

</div>

I am sorry but I am beginner with node-red so it will be best to swap Reset node with delay node?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2022 10:24 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/7 "2022-10-28T10:24:23Z")

</div>

> [@aquapark\_lodz](#):
>
> So with trigger node I must prevent other buttons to activate other sequences for 120 seconds

That is something you left out in your original post BUT it is easy enough to handle, just edit the `trigger` node and change it like this:

 ![Screen Shot 2022-10-28 at 6.28.54 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c2ee2e0b51df624d07f198266f4e893393a626e.png)

and you can get rid of the 'Reset' button

[EDIT] changed the `then send` to `nothing`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:26 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/8 "2022-10-28T10:26:24Z")

</div>

(Sorry again)

But neither of the flows allow toggling of the output.

But that could be handled after the `switch` node with a `function` node that toggles.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:27 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/9 "2022-10-28T10:27:29Z")

</div>

@aquapark_lodz do you want all 3 buttons **disabled** for 120 seconds though?

So you press a button and can't press another for 120 seconds?

Or just don't want more than one pressed at any one time?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2022 10:31 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/10 "2022-10-28T10:31:32Z")

</div>

> [@zenofmud](#):
>
> [EDIT] changed the `then send` to `nothing`

My original image needed a change

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [28 October 2022 10:32 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/11 "2022-10-28T10:32:05Z")

</div>

Here's a very quick modification of the flow created by @zenofmud  
Once a button has been clicked, the delay is triggered so further clicks are ignored until 'msg.reset'.

 ![delay_after](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/41bc888066c1bdc5e557544ee91e6be620c41325.png)

```auto
[{"id":"f34f56a1202cdf00","type":"tab","label":"Flow 15","disabled":false,"info":"","env":[]},{"id":"ed9404a32493f348","type":"inject","z":"f34f56a1202cdf00","name":"button 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 1","payloadType":"str","x":240,"y":240,"wires":[["fa397cd50e53da64"]]},{"id":"5d44870ef3d8fcc9","type":"debug","z":"f34f56a1202cdf00","name":"relay 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":240,"wires":[]},{"id":"542ec01399d74cdf","type":"inject","z":"f34f56a1202cdf00","name":"button 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 2","payloadType":"str","x":240,"y":300,"wires":[["fa397cd50e53da64"]]},{"id":"f6aac4011f02294d","type":"inject","z":"f34f56a1202cdf00","name":"button 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 3","payloadType":"str","x":240,"y":360,"wires":[["fa397cd50e53da64"]]},{"id":"504994e68a6fd402","type":"debug","z":"f34f56a1202cdf00","name":"relay 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":300,"wires":[]},{"id":"8ab0c75a9b116c02","type":"debug","z":"f34f56a1202cdf00","name":"relay 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":360,"wires":[]},{"id":"4974e765e65fc82b","type":"switch","z":"f34f56a1202cdf00","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"button 1","vt":"str"},{"t":"eq","v":"button 2","vt":"str"},{"t":"eq","v":"button 3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":650,"y":300,"wires":[["5d44870ef3d8fcc9"],["504994e68a6fd402"],["8ab0c75a9b116c02"]]},{"id":"fa397cd50e53da64","type":"trigger","z":"f34f56a1202cdf00","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":440,"y":300,"wires":[["4974e765e65fc82b","07583bb85bf30d06"]]},{"id":"7b5fb12647fcae7d","type":"inject","z":"f34f56a1202cdf00","name":"button ","props":[{"p":"reset","v":"reset","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":230,"y":460,"wires":[[]]},{"id":"07583bb85bf30d06","type":"delay","z":"f34f56a1202cdf00","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":620,"y":460,"wires":[["e5419a445b1844ec"]]},{"id":"e5419a445b1844ec","type":"function","z":"f34f56a1202cdf00","name":"Send 'reset'","func":"msg.reset = \"reset\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":560,"wires":[["fa397cd50e53da64"]]},{"id":"1a3d81f05446697a","type":"comment","z":"f34f56a1202cdf00","name":"Change this to 120 sec","info":"","x":660,"y":400,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![aquapark\_lodz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aquapark_lodz/32/69828_2.png) [@aquapark\_lodz](https://discourse.nodered.org/u/aquapark_lodz)\
**Post date:** [28 October 2022 10:36 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/12 "2022-10-28T10:36:10Z")

</div>

So I correct my node with sugestions but nothing happened.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/12c31d7f91112592d2d76fcb145065596cdfeb00.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/549394bcd52be5193e8db8bcdabaf8b4b99bcfcb.png)

I setup trigger for 5 seconds to test it but with trigger node on the startup it's only delay time for 5 seconds from push button to working rest of the code.

My goal is as follow:  
we have 3 physical buttons:  
Yellow button - to start some sequence with relays - working time 120 seconds  
Blue button - to start some sequence with relays - working time 120 seconds  
Red button - to start some sequence with relays - working time 120 seconds

When I push for example blue button and start some sequence for 120 seconds I want to prevent to push other buttons to start yellow button and red button sequence when blue button sequence is working at the moment. when the sequence is over I can again choice which of 3 sequences I can use

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2022 10:38 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/13 "2022-10-28T10:38:46Z")

</div>

please export your flow and attach it to a response and I'll take a look.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:42 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/14 "2022-10-28T10:42:14Z")

</div>

(That's what mine did) 😉

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [28 October 2022 10:44 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/15 "2022-10-28T10:44:57Z")

</div>

So it does - just imported your flow.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:46 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/16 "2022-10-28T10:46:42Z")

</div>

The _problem_ with the flow as is, that the relay/s will never be turned off.

You need to do just a bit more between the `switch` node and the `GPIO-OUT` node.

Basically you need a `function` node to receive the message and toggle what is sent to the GPIO pin.

One on each of the outputs.

(code in the `function` node as best I can make it just now)

```auto
let x = context.get("state") || 0;

x = (x + 1)%2;
context.set("state",x);

msg.payload = x;
return msg;

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:47 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/17 "2022-10-28T10:47:24Z")

</div>

Great minds think alike.

(Or is it: fools seldom differ?)  
😉

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 October 2022 10:50 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/18 "2022-10-28T10:50:19Z")

</div>

Try this:

```auto
[{"id":"fa397cd50e53da64","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":2900,"y":3950,"wires":[["4974e765e65fc82b","5208e2ef16afd9b6"]]},{"id":"ed9404a32493f348","type":"inject","z":"0918ee609bf69fc7","name":"button 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 1","payloadType":"str","x":2700,"y":3890,"wires":[["fa397cd50e53da64"]]},{"id":"542ec01399d74cdf","type":"inject","z":"0918ee609bf69fc7","name":"button 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 2","payloadType":"str","x":2700,"y":3950,"wires":[["fa397cd50e53da64"]]},{"id":"f6aac4011f02294d","type":"inject","z":"0918ee609bf69fc7","name":"button 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"button 3","payloadType":"str","x":2700,"y":4010,"wires":[["fa397cd50e53da64"]]},{"id":"90312086218313de","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3070,"y":4060,"wires":[["fa397cd50e53da64"]]},{"id":"4974e765e65fc82b","type":"switch","z":"0918ee609bf69fc7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"button 1","vt":"str"},{"t":"eq","v":"button 2","vt":"str"},{"t":"eq","v":"button 3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":3110,"y":3950,"wires":[["566dbfc5ddf752d7"],["17791fe1e8c5822f"],["db9ec301df7146f5"]]},{"id":"5208e2ef16afd9b6","type":"delay","z":"0918ee609bf69fc7","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":3050,"y":4020,"wires":[["90312086218313de"]]},{"id":"566dbfc5ddf752d7","type":"function","z":"0918ee609bf69fc7","name":"function 1","func":"let x = context.get(\"state\") || 0;\n\nx = (x + 1) % 2;\ncontext.set(\"state\", x);\n\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3290,"y":3890,"wires":[["5d44870ef3d8fcc9"]]},{"id":"17791fe1e8c5822f","type":"function","z":"0918ee609bf69fc7","name":"function 2","func":"let x = context.get(\"state\") || 0;\n\nx = (x + 1) % 2;\ncontext.set(\"state\", x);\n\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3300,"y":3950,"wires":[["504994e68a6fd402"]]},{"id":"db9ec301df7146f5","type":"function","z":"0918ee609bf69fc7","name":"function 3","func":"let x = context.get(\"state\") || 0;\n\nx = (x + 1) % 2;\ncontext.set(\"state\", x);\n\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3300,"y":4010,"wires":[["8ab0c75a9b116c02"]]},{"id":"5d44870ef3d8fcc9","type":"debug","z":"0918ee609bf69fc7","name":"relay 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3490,"y":3890,"wires":[]},{"id":"504994e68a6fd402","type":"debug","z":"0918ee609bf69fc7","name":"relay 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3490,"y":3950,"wires":[]},{"id":"8ab0c75a9b116c02","type":"debug","z":"0918ee609bf69fc7","name":"relay 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3490,"y":4010,"wires":[]}]

```

Change the `5` seconds to `120` of course.

---

<div class="post-metadata">

**Author:** ![aquapark\_lodz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aquapark_lodz/32/69828_2.png) [@aquapark\_lodz](https://discourse.nodered.org/u/aquapark_lodz)\
**Post date:** [28 October 2022 10:55 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/19 "2022-10-28T10:55:49Z")

</div>

Thank you for such support I am very grateful for your time.  
So I attach photo of my desk to test

 ![20221028_124357](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/90738af587cd520a02823ca7487b97c0958ad0d4.jpeg)

You can see that I want to make sequences for each buttons: for example when I push blue button the sequence starts: 10 seconds to open relay number 1, 2, and then relay 1, 2 close and relay number 5, 7 open for 15 seconds, and then relay number 10, 11 open for specific time. I have to think also to add rgb light to this and sound. So it will be the whole sequence for one button during 120 seconds.

my code is below

```auto
[
    {
        "id": "a7c04de751f0d70c",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "71c5874690970252",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "RED-ON",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 300,
        "y": 280,
        "wires": [
            [
                "40df411fb5f96a2c"
            ]
        ]
    },
    {
        "id": "40df411fb5f96a2c",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 17 - RED",
        "pin": "17",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 560,
        "y": 280,
        "wires": []
    },
    {
        "id": "46de8f397d8c30a1",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "RED-OFF",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 300,
        "y": 320,
        "wires": [
            [
                "40df411fb5f96a2c"
            ]
        ]
    },
    {
        "id": "ef66caf2b21542a9",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 27 - BLUE",
        "pin": "27",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 560,
        "y": 400,
        "wires": []
    },
    {
        "id": "b88acd49fd7f9063",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "BLUE-ON",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 300,
        "y": 380,
        "wires": [
            [
                "ef66caf2b21542a9"
            ]
        ]
    },
    {
        "id": "cba5f36ac3613151",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "BLUE-OFF",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 300,
        "y": 420,
        "wires": [
            [
                "ef66caf2b21542a9"
            ]
        ]
    },
    {
        "id": "033fcf1c4f2338fe",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GREEN-ON",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 310,
        "y": 480,
        "wires": [
            [
                "ac23678b6847aab2"
            ]
        ]
    },
    {
        "id": "02863a3a36443f1f",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GREEN-OFF",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 310,
        "y": 520,
        "wires": [
            [
                "ac23678b6847aab2"
            ]
        ]
    },
    {
        "id": "ac23678b6847aab2",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 23 - GREEN",
        "pin": "23",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 570,
        "y": 500,
        "wires": []
    },
    {
        "id": "00220d4e445fbed3",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 18 - 1 relay",
        "pin": "18",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 640,
        "wires": []
    },
    {
        "id": "b4d9913244bee701",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 18 - 1 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 620,
        "wires": [
            [
                "00220d4e445fbed3"
            ]
        ]
    },
    {
        "id": "6c678d10e23c9564",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 18 - 1 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 680,
        "wires": [
            [
                "00220d4e445fbed3"
            ]
        ]
    },
    {
        "id": "180611fd8dd658ca",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 4 - 2 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 740,
        "wires": [
            [
                "22f07224c42d5ae0"
            ]
        ]
    },
    {
        "id": "a03b07af069d06d8",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 4 - 2 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 800,
        "wires": [
            [
                "22f07224c42d5ae0"
            ]
        ]
    },
    {
        "id": "22f07224c42d5ae0",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 4 - 2 relay",
        "pin": "4",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 580,
        "y": 760,
        "wires": []
    },
    {
        "id": "86ec22e13688bf46",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 22 - 3 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 860,
        "wires": [
            [
                "20f17aa86bd3900d"
            ]
        ]
    },
    {
        "id": "3094eac688372230",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 22 - 3 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 920,
        "wires": [
            [
                "20f17aa86bd3900d"
            ]
        ]
    },
    {
        "id": "20f17aa86bd3900d",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 22 - 3 relay",
        "pin": "22",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 880,
        "wires": []
    },
    {
        "id": "c75f3d81966f4a42",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 5 - 4 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 980,
        "wires": [
            [
                "a22644f09c453d6b"
            ]
        ]
    },
    {
        "id": "546bed0d4a38a0c7",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 5 - 4 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 1040,
        "wires": [
            [
                "a22644f09c453d6b"
            ]
        ]
    },
    {
        "id": "a22644f09c453d6b",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 5 - 4 relay",
        "pin": "5",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 580,
        "y": 1000,
        "wires": []
    },
    {
        "id": "dc30e5217dcba658",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 6 - 5 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1100,
        "wires": [
            [
                "b97a719da33147cc"
            ]
        ]
    },
    {
        "id": "eda1bbe67363472f",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 6 - 5 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 1160,
        "wires": [
            [
                "b97a719da33147cc"
            ]
        ]
    },
    {
        "id": "b97a719da33147cc",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 6 - 5 relay",
        "pin": "6",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 580,
        "y": 1120,
        "wires": []
    },
    {
        "id": "fb89175ab1fb44d6",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 13 - 6 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1220,
        "wires": [
            [
                "9e44fc7bb5a6f6c7"
            ]
        ]
    },
    {
        "id": "1e429d2368eb3d50",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 13 - 6 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 1280,
        "wires": [
            [
                "9e44fc7bb5a6f6c7"
            ]
        ]
    },
    {
        "id": "9e44fc7bb5a6f6c7",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 13 - 6 relay",
        "pin": "13",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1240,
        "wires": []
    },
    {
        "id": "692677f4f265f945",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 19 - 7 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1340,
        "wires": [
            [
                "a162c62bf410cb2f"
            ]
        ]
    },
    {
        "id": "2cc69d3a52ca883e",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 19 - 7 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 1400,
        "wires": [
            [
                "a162c62bf410cb2f"
            ]
        ]
    },
    {
        "id": "a162c62bf410cb2f",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 19 - 7 relay",
        "pin": "19",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1360,
        "wires": []
    },
    {
        "id": "a18f6efe250b26c7",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 24 - 8 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1460,
        "wires": [
            [
                "abf0336989dd502b"
            ]
        ]
    },
    {
        "id": "65a68a9793e78878",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 24 - 8 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 1520,
        "wires": [
            [
                "abf0336989dd502b"
            ]
        ]
    },
    {
        "id": "abf0336989dd502b",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 24 - 8 relay",
        "pin": "24",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1480,
        "wires": []
    },
    {
        "id": "ea7b7e54ea9c3542",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 25 - 9 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1580,
        "wires": [
            [
                "c89736665c727dd6"
            ]
        ]
    },
    {
        "id": "80e0b13e899f352d",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 25 - 9 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 1640,
        "wires": [
            [
                "c89736665c727dd6"
            ]
        ]
    },
    {
        "id": "c89736665c727dd6",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 25 - 9 relay",
        "pin": "25",
        "set": false,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1600,
        "wires": []
    },
    {
        "id": "2971eb4001b641ea",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 12 - 10 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1700,
        "wires": [
            [
                "755919522cdeadca"
            ]
        ]
    },
    {
        "id": "994f20862b19b7d4",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 12 - 10 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 350,
        "y": 1760,
        "wires": [
            [
                "755919522cdeadca"
            ]
        ]
    },
    {
        "id": "755919522cdeadca",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 12 - 10 relay",
        "pin": "12",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1720,
        "wires": []
    },
    {
        "id": "eef14abb7f1f0943",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 16 - 11 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1820,
        "wires": [
            [
                "a782108a520dd316"
            ]
        ]
    },
    {
        "id": "b2c37c4ac1def429",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 16 - 11 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 350,
        "y": 1880,
        "wires": [
            [
                "a782108a520dd316"
            ]
        ]
    },
    {
        "id": "a782108a520dd316",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 16 - 11 relay",
        "pin": "16",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1840,
        "wires": []
    },
    {
        "id": "6d06cd5560b2d01c",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 12 - 12 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 1940,
        "wires": [
            [
                "34160d1c4ca0d429"
            ]
        ]
    },
    {
        "id": "26b7778655c61dfa",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 12 - 12 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 350,
        "y": 2000,
        "wires": [
            [
                "34160d1c4ca0d429"
            ]
        ]
    },
    {
        "id": "34160d1c4ca0d429",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 20 - 12 relay",
        "pin": "20",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 1960,
        "wires": []
    },
    {
        "id": "785c3c87278d24d1",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 26 - 13 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 2060,
        "wires": [
            [
                "058763cf1630e937"
            ]
        ]
    },
    {
        "id": "985b6a325e9fc820",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 26 - 13 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 350,
        "y": 2120,
        "wires": [
            [
                "058763cf1630e937"
            ]
        ]
    },
    {
        "id": "058763cf1630e937",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 26 - 13 relay",
        "pin": "26",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 2080,
        "wires": []
    },
    {
        "id": "1b920d2c6466dd9b",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 21 - 14 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 2180,
        "wires": [
            [
                "687597d052585521"
            ]
        ]
    },
    {
        "id": "58f2127b06970b19",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 21 - 14 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 350,
        "y": 2240,
        "wires": [
            [
                "687597d052585521"
            ]
        ]
    },
    {
        "id": "687597d052585521",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 21 - 14 relay",
        "pin": "21",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 2200,
        "wires": []
    },
    {
        "id": "281aeb11f1837b3c",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 10 - 15 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 2300,
        "wires": [
            [
                "2a5f093afde59f9f"
            ]
        ]
    },
    {
        "id": "14486318ad2799a5",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 10 - 15 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 350,
        "y": 2360,
        "wires": [
            [
                "2a5f093afde59f9f"
            ]
        ]
    },
    {
        "id": "2a5f093afde59f9f",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 10 - 15 relay",
        "pin": "10",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 2320,
        "wires": []
    },
    {
        "id": "122b28cd8178aaae",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 9 - 16 relay [ON]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 340,
        "y": 2420,
        "wires": [
            [
                "61dc8a60d5b5dcc5"
            ]
        ]
    },
    {
        "id": "01021f15b5af9107",
        "type": "inject",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 9 - 16 relay [OFF]",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 340,
        "y": 2480,
        "wires": [
            [
                "61dc8a60d5b5dcc5"
            ]
        ]
    },
    {
        "id": "61dc8a60d5b5dcc5",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 9 - 16 relay",
        "pin": "9",
        "set": true,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 590,
        "y": 2440,
        "wires": []
    },
    {
        "id": "13cd8768c66047f5",
        "type": "rpi-gpio in",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 11 - Yellow Button",
        "pin": "11",
        "intype": "tri",
        "debounce": "100",
        "read": false,
        "bcm": true,
        "x": 900,
        "y": 2620,
        "wires": [
            [
                "61fa470f1877e278"
            ]
        ]
    },
    {
        "id": "33eff1e864e8377e",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 9 - 16 relay",
        "pin": "9",
        "set": false,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1570,
        "y": 2600,
        "wires": []
    },
    {
        "id": "4620a3d01878af9b",
        "type": "rpi-gpio in",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 14 - Blue Button",
        "pin": "14",
        "intype": "tri",
        "debounce": "100",
        "read": false,
        "bcm": true,
        "x": 900,
        "y": 2700,
        "wires": [
            []
        ]
    },
    {
        "id": "6b3c06b7f78b94e4",
        "type": "rpi-gpio in",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 15 - Blue Button",
        "pin": "15",
        "intype": "tri",
        "debounce": "100",
        "read": false,
        "bcm": true,
        "x": 900,
        "y": 2780,
        "wires": [
            []
        ]
    },
    {
        "id": "db0502faea8be49f",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 10 - 15 relay",
        "pin": "10",
        "set": false,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1570,
        "y": 2680,
        "wires": []
    },
    {
        "id": "cc4bb08dbcf7e3cf",
        "type": "rpi-gpio out",
        "z": "a7c04de751f0d70c",
        "name": "GPIO 21 - 14 relay",
        "pin": "21",
        "set": false,
        "level": "1",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1570,
        "y": 2760,
        "wires": []
    },
    {
        "id": "61fa470f1877e278",
        "type": "trigger",
        "z": "a7c04de751f0d70c",
        "name": "",
        "op1": "",
        "op2": "0",
        "op1type": "pay",
        "op2type": "str",
        "duration": "0",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1140,
        "y": 2620,
        "wires": [
            [
                "72ac56deb16e20c9",
                "fa8a042992930565"
            ]
        ]
    },
    {
        "id": "7ad0d6f4b25968fc",
        "type": "function",
        "z": "a7c04de751f0d70c",
        "name": "Send 'reset'",
        "func": "msg.reset = \"reset\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1130,
        "y": 2440,
        "wires": [
            [
                "61fa470f1877e278"
            ]
        ]
    },
    {
        "id": "72ac56deb16e20c9",
        "type": "switch",
        "z": "a7c04de751f0d70c",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "GPIO 11 - Yellow Button",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "GPIO 14 - Blue Button",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "GPIO 15 - Blue Button",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 1350,
        "y": 2620,
        "wires": [
            [
                "33eff1e864e8377e"
            ],
            [
                "db0502faea8be49f"
            ],
            [
                "cc4bb08dbcf7e3cf"
            ]
        ]
    },
    {
        "id": "fa8a042992930565",
        "type": "delay",
        "z": "a7c04de751f0d70c",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1340,
        "y": 2500,
        "wires": [
            [
                "7ad0d6f4b25968fc"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![aquapark\_lodz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aquapark_lodz/32/69828_2.png) [@aquapark\_lodz](https://discourse.nodered.org/u/aquapark_lodz)\
**Post date:** [28 October 2022 11:32 UTC](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722/20 "2022-10-28T11:32:20Z")

</div>

Trying\_to\_learn  
I have just tried your code but with no result

[Next page](https://discourse.nodered.org/t/multiple-physical-buttons-gpio-only-one-push-button-at-a-time-rgb-strip-and-relays-sequence-with-variable-delays/69722.md?page=2)
