# AND gate inputs

**URL:** <https://discourse.nodered.org/t/and-gate-inputs/4197>\
**Category:** General\
**Created:** [22 October 2018 19:54 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197 "2018-10-22T19:54:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [22 October 2018 19:54 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/1 "2018-10-22T19:54:23Z")

</div>

Hi  
I have this flow below and i want to put AND gate so when the output of the function (Calculate Percentage) decreased to 10 the AND gate gives output so I can run on of GPIOs of the raspberry pi.  
I put the AND gate and set the topics for the (Calculate Percentage) with number less than 10 and Inject node (less) with number ==10.  
but I think there is something wrong.  
please advise where is the mistake in this setting

`[{"id":"b35f6956.6db678","type":"rpi-srf","z":"dae97729.e9eed8","name":"Sensor","topic":"","pulse":"0.5","pins":"37,38","x":108,"y":155,"wires":[["616ac931.29b938"]]},{"id":"616ac931.29b938","type":"function","z":"dae97729.e9eed8","name":"Calculate Percentage","func":"var distance = parseInt(msg.payload);\nvar EmptyDist = 100 -distance;\nmsg.payload = parseInt((EmptyDist/100)*100);\n//msg.payload =(100- parseInt((temp/125)*100));\nreturn msg;\n","outputs":1,"noerr":0,"x":309,"y":155,"wires":[["cd2a360c.cbed68","f1ae908b.e85ce"]]},{"id":"39f04960.f55496","type":"debug","z":"dae97729.e9eed8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":628,"y":252,"wires":[]},{"id":"cd2a360c.cbed68","type":"ui_gauge","z":"dae97729.e9eed8","name":"","group":"2cad78f1.953508","order":0,"width":"6","height":"7","gtype":"gage","title":"Tank Filled","label":"Percentage","format":"{{value}}","min":0,"max":"100","colors":["#b52100","#e6e600","#42ca38"],"seg1":"","seg2":"","x":661,"y":120,"wires":[]},{"id":"f1ae908b.e85ce","type":"and-gate","z":"dae97729.e9eed8","name":"","rules":[{"t":"lt","v":"10","vt":"num","propertyType":"msg","property":"payload","topic":"Calculate Percentage"},{"t":"eq","v":"10","vt":"num","propertyType":"msg","property":"payload","topic":"less"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":false,"x":373,"y":267,"wires":[["39f04960.f55496"]]},{"id":"8c0273fa.30168","type":"inject","z":"dae97729.e9eed8","name":"","topic":"less","payload":"10","payloadType":"num","repeat":".2","crontab":"","once":false,"onceDelay":0.1,"x":121,"y":301,"wires":[["f1ae908b.e85ce"]]},{"id":"2cad78f1.953508","type":"ui_group","z":"","name":"Mustafa","tab":"9f2b0241.7a073","disp":true,"width":"6","collapse":false},{"id":"9f2b0241.7a073","type":"ui_tab","z":"","name":"Home","icon":"my dash","order":2}]`

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 October 2018 20:30 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/2 "2018-10-22T20:30:05Z")

</div>

Which And gate are you using, you presumably installed node-red-contrib-something?  
Where are you setting the topic for the Calculate Percentage input?

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [22 October 2018 20:51 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/3 "2018-10-22T20:51:41Z")

</div>

AND gate from node-red-contrib-bool-gate  
please see the screenshot ![AND](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/772d22826438abb9f88831d5de88e6a6feac6c4f.jpeg)

---

<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:** [22 October 2018 21:53 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/4 "2018-10-22T21:53:14Z")

</div>

So you are using an AND gate and the output will be true if both conditions are true  
However you are testing msg.payload to be equal to 10 AND less than 10

do you see an issue with that?

---

<div class="post-metadata">

**Author:** ![Riven5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riven5/32/2887_2.png) [@Riven5](https://discourse.nodered.org/u/Riven5)\
**Post date:** [23 October 2018 02:30 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/5 "2018-10-23T02:30:09Z")

</div>

@zenofmud That's a perfectly valid AND gate configuration. The topics are read separately. It's a workaround for nodered's lack of multiple-input nodes.

@mustafa The topic of the sensor node is blank. Based on the gate configuration, it should be "Calculate Percentage".

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 October 2018 06:14 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/6 "2018-10-23T06:14:09Z")

</div>

You have not answered my question, where are you setting the topic for the percentage message?

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [23 October 2018 07:38 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/7 "2018-10-23T07:38:32Z")

</div>

the AND gate connected between function node named (Calculate Percentage) and inject node named (less) , why shall I set the topic of the sensor node?? please explain to me

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [23 October 2018 07:49 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/8 "2018-10-23T07:49:11Z")

</div>

Do you mean in the AND gate must be a setting for the topic of Calculate Percentage?

---

<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:** [23 October 2018 08:43 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/9 "2018-10-23T08:43:05Z")

</div>

@Riven5 oops, your right, I don't know how missed the inject 🤔

@mustafa - the node works by looking at the topic of the msg and matching that to the first part of the each AND condition. It would make a lot more sense if the author had named the first part of each condition "Topic'`

---

<div class="post-metadata">

**Author:** ![Riven5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/riven5/32/2887_2.png) [@Riven5](https://discourse.nodered.org/u/Riven5)\
**Post date:** [23 October 2018 21:31 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/10 "2018-10-23T21:31:27Z")

</div>

Just in case you're still not clear on why: the names of the nodes are ignored. Only the topic matters. I said to set the topic in the sensor node because that is the origin, but you can set it in the function node if you prefer. `msg.topic = "Calculate Percentage"`

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [29 October 2018 08:52 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/11 "2018-10-29T08:52:42Z")

</div>

Hi All  
Please see below the flow  
`[{"id":"b35f6956.6db678","type":"rpi-srf","z":"dae97729.e9eed8","name":"Sensor","topic":"Calculate Percentage","pulse":"0.5","pins":"37,38","x":108,"y":155,"wires":[["616ac931.29b938"]]},{"id":"39f04960.f55496","type":"debug","z":"dae97729.e9eed8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":628,"y":252,"wires":[]},{"id":"cd2a360c.cbed68","type":"ui_gauge","z":"dae97729.e9eed8","name":"","group":"2cad78f1.953508","order":0,"width":"6","height":"7","gtype":"gage","title":"Tank Filled","label":"Percentage","format":"{{value}}","min":0,"max":"100","colors":["#b52100","#e6e600","#42ca38"],"seg1":"","seg2":"","x":661,"y":120,"wires":[]},{"id":"f1ae908b.e85ce","type":"and-gate","z":"dae97729.e9eed8","name":"","rules":[{"t":"lt","v":"10","vt":"num","propertyType":"msg","property":"payload","topic":"Calculate Percentage"},{"t":"eq","v":"10","vt":"num","propertyType":"msg","property":"payload","topic":"less"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":false,"x":378,"y":322,"wires":[["e1487b82.6dfe98","39f04960.f55496"]]},{"id":"8c0273fa.30168","type":"inject","z":"dae97729.e9eed8","name":"","topic":"less","payload":"10","payloadType":"num","repeat":"0.5","crontab":"","once":false,"onceDelay":0.1,"x":121,"y":301,"wires":[["f1ae908b.e85ce"]]},{"id":"e1487b82.6dfe98","type":"rpi-gpio out","z":"dae97729.e9eed8","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":563,"y":414,"wires":[]},{"id":"616ac931.29b938","type":"function","z":"dae97729.e9eed8","name":"Calculate Percentage","func":"var distance = parseInt(msg.payload);\nvar EmptyDist = 100 -distance;\nmsg.payload = parseInt((EmptyDist/100)*100);\n//msg.payload =(100- parseInt((temp/125)*100));\nreturn msg;\n","outputs":1,"noerr":0,"x":309,"y":155,"wires":[["cd2a360c.cbed68","f1ae908b.e85ce"]]},{"id":"2cad78f1.953508","type":"ui_group","z":"","name":"Mustafa","tab":"9f2b0241.7a073","disp":true,"width":"6","collapse":false},{"id":"9f2b0241.7a073","type":"ui_tab","z":"","name":"Home","icon":"my dash","order":2}]`

I set the msg.topic = "Calculate Percentage" in the sensor node and fit the distance arround 6 percent and connect the debug on the AND gate output then i got the debug as below :  
0/23/2018, 2:54:19 PMnode: e1487b82.6dfe98  
msg : string[17]  
"Invalid input: 10"  
10/23/2018, 2:54:19 PMnode: 39f04960.f55496  
msg.payload : number  
10  
10/23/2018, 2:54:19 PMnode: e1487b82.6dfe98  
msg : string[17]  
"Invalid input: 10"  
10/23/2018, 2:54:19 PMnode: 39f04960.f55496  
msg.payload : number  
10  
10/23/2018, 2:54:19 PMnode: e1487b82.6dfe98  
msg : string[16]  
"Invalid input: 6"  
10/23/2018, 2:54:19 PMnode: 39f04960.f55496  
msg.payload : number  
6  
10/23/2018, 2:54:19 PMnode: 979e0d81.a137  
msg.payload : number  
4  
10/23/2018, 2:54:19 PMnode: 979e0d81.a137  
msg.payload : number  
6  
10/23/2018, 2:54:23 PMnode: e1487b82.6dfe98  
msg : string[17]  
"Invalid input: 10"  
10/23/2018, 2:54:23 PMnode: 39f04960.f55496  
msg.payload : number  
10  
10/23/2018, 2:54:23 PMnode: e1487b82.6dfe98  
msg : string[17]  
"Invalid input: 10"  
10/23/2018, 2:54:23 PMnode: 39f04960.f55496  
msg.payload : number  
10  
10/23/2018, 2:54:23 PMnode: e1487b82.6dfe98  
msg : string[16]  
"Invalid input: 6"  
10/23/2018, 2:54:23 PMnode: 39f04960.f55496  
msg.payload : number  
6  
10/23/2018, 2:54:23 PMnode: 979e0d81.a137  
msg.payload : number  
7

it seems that the debug output is reading periodically the output of the inject node which is 10 and the read after that the actual distance which is 7 percent and no output from the GPIO.  
any idea please ??

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 October 2018 09:13 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/12 "2018-10-29T09:13:08Z")

</div>

First have a look at the info tab for the and gate. Particularly notice what it says about what is in msg.payload of the output message and what is in msg.bool of the output message.  
Also put a debug on the output of the function node to check exactly what is in that message that would explain the "Invalid Input: 10" messages. If it looks ok then post that here.

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [29 October 2018 09:49 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/13 "2018-10-29T09:49:22Z")

</div>

The output of the function node is ( 10/23/2018, 3:44:22 PMnode: 979e0d81.a137  
msg.payload : number  
-136  
10/23/2018, 3:44:23 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-135  
10/23/2018, 3:44:23 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
49  
10/23/2018, 3:44:24 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-135  
10/23/2018, 3:44:25 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:25 PMnode: 979e0d81.a137  
msg.payload : number  
80  
10/23/2018, 3:44:25 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
78  
10/23/2018, 3:44:26 PMnode: 979e0d81.a137  
msg.payload : number  
85  
10/23/2018, 3:44:26 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
87  
10/23/2018, 3:44:26 PMnode: 979e0d81.a137  
msg.payload : number  
86  
10/23/2018, 3:44:26 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
86  
10/23/2018, 3:44:27 PMnode: 979e0d81.a137  
msg.payload : number  
87  
10/23/2018, 3:44:27 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
87  
10/23/2018, 3:44:28 PMnode: 979e0d81.a137  
msg.payload : number  
88  
10/23/2018, 3:44:28 PMnode: 979e0d81.a137  
msg.payload : number  
90  
10/23/2018, 3:44:28 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
90  
10/23/2018, 3:44:29 PMnode: 979e0d81.a137  
msg.payload : number  
91  
10/23/2018, 3:44:29 PMnode: 979e0d81.a137  
msg.payload : number  
89  
10/23/2018, 3:44:29 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
89  
10/23/2018, 3:44:30 PMnode: 979e0d81.a137  
msg.payload : number  
91  
10/23/2018, 3:44:30 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
91  
10/23/2018, 3:44:30 PMnode: 979e0d81.a137  
msg.payload : number  
92  
10/23/2018, 3:44:31 PMnode: 979e0d81.a137  
msg.payload : number  
91  
10/23/2018, 3:44:32 PMnode: 979e0d81.a137  
msg.payload : number  
92  
10/23/2018, 3:44:32 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
90  
10/23/2018, 3:44:32 PMnode: 979e0d81.a137  
msg.payload : number  
91  
10/23/2018, 3:44:33 PMnode: 979e0d81.a137  
msg.payload : number  
92  
10/23/2018, 3:44:33 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
91  
10/23/2018, 3:44:33 PMnode: 979e0d81.a137  
msg.payload : number  
91  
10/23/2018, 3:44:34 PMnode: 979e0d81.a137  
msg.payload : number  
92  
10/23/2018, 3:44:34 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
90  
10/23/2018, 3:44:34 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
92  
10/23/2018, 3:44:36 PMnode: 979e0d81.a137  
msg.payload : number  
91  
10/23/2018, 3:44:36 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
88  
10/23/2018, 3:44:36 PMnode: 979e0d81.a137  
msg.payload : number  
-136  
10/23/2018, 3:44:36 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-137  
10/23/2018, 3:44:37 PMnode: 979e0d81.a137  
msg.payload : number  
45  
10/23/2018, 3:44:37 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-27  
10/23/2018, 3:44:37 PMnode: 979e0d81.a137  
msg.payload : number  
47  
10/23/2018, 3:44:37 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-137  
10/23/2018, 3:44:38 PMnode: 979e0d81.a137  
msg.payload : number  
-136  
10/23/2018, 3:44:38 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-38  
10/23/2018, 3:44:38 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:39 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-137  
10/23/2018, 3:44:39 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:40 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-138  
10/23/2018, 3:44:40 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:42 PMnode: 979e0d81.a137  
msg.payload : number  
-137  
10/23/2018, 3:44:42 PMnode: 979e0d81.a137  
msg.payload : number  
-135  
10/23/2018, 3:44:42 PMnode: 979e0d81.a137  
msg.payload : number  
-136  
10/23/2018, 3:44:42 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-110  
10/23/2018, 3:44:43 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-135  
10/23/2018, 3:44:43 PMnode: 979e0d81.a137  
msg.payload : number  
-135  
10/23/2018, 3:44:43 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-131  
10/23/2018, 3:44:44 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:44 PMnode: 979e0d81.a137  
msg.payload : number  
-136  
10/23/2018, 3:44:44 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-109  
10/23/2018, 3:44:45 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:46 PMnode: 979e0d81.a137  
msg.payload : number  
39  
10/23/2018, 3:44:46 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
18  
10/23/2018, 3:44:46 PMnode: 979e0d81.a137  
msg.payload : number  
-137  
10/23/2018, 3:44:47 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-21  
10/23/2018, 3:44:47 PMnode: 979e0d81.a137  
msg.payload : number  
-135  
10/23/2018, 3:44:47 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-136  
10/23/2018, 3:44:47 PMnode: 39f04960.f55496  
Calculate Percentage : msg.payload : number  
-135)

and regarding to the AND gate info tab is says: ( payload string | object

the payload of the message that trigged the node

bool /bool

the result of the node)

what suppose the output of the AND gate must be ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 October 2018 10:09 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/14 "2018-10-29T10:09:33Z")

</div>

We don't need to see dozens of results, just the output of the function node when you get the "illegal value" message from the AND gate. Disable the AND gate debug while you are looking for that so the output is easier to read.

If you want to send the result of the AND operation to the GPIO pin then you must use the value of msg.bool as it says in the info. I would not have designed the gate like that, I would have put the boolean output in the payload which is what you have assumed will happen. However, as it says in the Info panel, it returns the result of the AND in msg.bool. The easiest thing is to put a Change node after the AND node. Configure it to Move msg.bool To msg.payload.

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [30 October 2018 18:50 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/15 "2018-10-30T18:50:03Z")

</div>

![change](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9cdfc4a23d31116d963b7fa181681f1eb631f8de.jpeg)  
is that correct for change node?  
still the GPIO not work while the on the flow the AND gate show the true status at level below 10 and false status at level above 10 percent

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [30 October 2018 19:14 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/16 "2018-10-30T19:14:46Z")

</div>

> Configure it to Move msg.bool To msg.payload.

To achieve the above in the Change node you:  
`Set` `msg.payload`  
`to` `msg.bool`

or

`Move` `msg.bool`  
`to` `msg.payload`

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [30 October 2018 19:30 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/17 "2018-10-30T19:30:15Z")

</div>

It is works now but the LED get ON when the distance less 10 and keep ON even after distance more than 10 when AND gate in false status  
any idea ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 October 2018 20:17 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/18 "2018-10-30T20:17:20Z")

</div>

Do you mean the AND gate changes state as it should, but the LED is not following the AND gate status display?  
If so first put a debug showing what is going to the GPIO pin and see if that is correct.

---

<div class="post-metadata">

**Author:** ![mustafa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mustafa/32/538_2.png) [@mustafa](https://discourse.nodered.org/u/mustafa)\
**Post date:** [30 October 2018 21:23 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/19 "2018-10-30T21:23:49Z")

</div>

Colin  
Exactlly as you says  
here is the debug  
10/31/2018, 12:19:55 AM[node: 979e0d81.a137](http://192.168.0.109:1880/#)msg : Object

object

topic: null

payload: true

bool: true

\_msgid: "7d766744.27a018"

I was selecting the option of True restriction in the AND gate so the it will gives output once the condition is true if not selected the LED always ON

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 October 2018 21:36 UTC](https://discourse.nodered.org/t/and-gate-inputs/4197/20 "2018-10-30T21:36:39Z")

</div>

> [@mustafa](#):
>
> I was selecting the option of True restriction in the AND gate

With that option selected it will send true when it becomes true, but will never send false. So how do you expect the led to change? Clear that option so the AND node should send true or false as the inputs change so the led will change state.

[Next page](https://discourse.nodered.org/t/and-gate-inputs/4197.md?page=2)
