# Please help with GPIO Status and IF statement trigger

**URL:** https://discourse.nodered.org/t/please-help-with-gpio-status-and-if-statement-trigger/30629
**Category:** General
**Created:** [23 July 2020 18:42 UTC](https://discourse.nodered.org/t/please-help-with-gpio-status-and-if-statement-trigger/30629 "2020-07-23T18:42:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Peter](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/peter/32/25135_2.png) [@Peter](https://discourse.nodered.org/u/Peter)
#### Post date: [23 July 2020 18:42 UTC](https://discourse.nodered.org/t/please-help-with-gpio-status-and-if-statement-trigger/30629/1 "2020-07-23T18:42:37Z")

</div>

Hallo Everyone,

Hope you could assist me with a challenge I face regards to a GPIO Status, to only receive an trigger 1 / 0 subject to its status .

My Flow starts with a GPIO 07 ( 0 = off / normal state ) and if triggered sends (1) to next "trigger" node that send out a number 1 to other OUT-GPIO's and need to trigger another specific OUT-GPIO ( GPIO05-29) only if the status of GPIO05-29 == 0 == do nothing ,but this is where my confusion / stupidity comes in play .... The Trigger Node sends a 1 and after 8 seconds a 0 , so how do i go about a if statement or switch node to check the status of GPIO05-29 is on (0) and if (0) , its needs to bet temp be switch off (1) for the period of the trigger node (8sec) and then be turned back to previous / original state (0) ...BUT if GPIO05-29 == 1 (off) then it should not receive ant payload from the trigger node that will send a 0 and 8 sec later 1 .

I hope i have explained it well enough and i will appreciate your help and support on this challenge.

Please see my flow below edited with only the critical portion for your connivance

```auto
[{"id":"dab3a29.e9af46","type":"rpi-gpio out","z":"8d9d129f.61bd1","name":"CH1 Relay / kunsmis pump ","pin":"29","set":false,"level":"1","freq":"","out":"out","x":1880,"y":100,"wires":[]},{"id":"2b8c3ce.82b5cc4","type":"inject","z":"8d9d129f.61bd1","name":"Status of GPIO / Realy state = 1","topic":"Status of GPIO 05-29 / Realy state","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1090,"y":100,"wires":[["dab3a29.e9af46","fb98d28d.44e4e"]]},{"id":"a89ea71f.c90318","type":"inject","z":"8d9d129f.61bd1","name":"Status of GPIO / Realy state = 0","topic":"Status of GPIO 05-29 / Realy state","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1090,"y":160,"wires":[["dab3a29.e9af46","fb98d28d.44e4e"]]},{"id":"6abc3aea.21d0f4","type":"function","z":"8d9d129f.61bd1","name":"Test IF ","func":"if (msg.payload.gpio1 == 1) {\nmsg.payload = 1;\nreturn msg;\n}\nelse{\n msg.payload = 0;\nreturn msg;\n}\n\n ","outputs":1,"noerr":0,"x":1650,"y":220,"wires":[["dab3a29.e9af46","fb98d28d.44e4e"]]},{"id":"fb98d28d.44e4e","type":"debug","z":"8d9d129f.61bd1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1830,"y":160,"wires":[]},{"id":"8c45fd1.e0b15","type":"trigger","z":"8d9d129f.61bd1","op1":"0","op2":"1","op1type":"num","op2type":"num","duration":"8","extend":false,"units":"s","reset":"0","bytopic":"all","name":"KunsmisPompTrigger","x":1440,"y":220,"wires":[["6abc3aea.21d0f4"]]},{"id":"9c2de007.8fe97","type":"inject","z":"8d9d129f.61bd1","name":"IN - GRIO 07-26 Trigger evengt = ON ","topic":"IN -GRIO 07-26 Trigger on = 1","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1110,"y":220,"wires":[["8c45fd1.e0b15"]]}]

```

![issue 5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d686b214d6b0afc05343b0fc6dcce7f4e1904790.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [21 September 2020 18:42 UTC](https://discourse.nodered.org/t/please-help-with-gpio-status-and-if-statement-trigger/30629/2 "2020-09-21T18:42:46Z")

</div>

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