# AND gate experiment

**URL:** <https://discourse.nodered.org/t/and-gate-experiment/24412>\
**Category:** General\
**Created:** [7 April 2020 15:19 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412 "2020-04-07T15:19:15Z")\
**Posts on this page:** 10\
**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:** [7 April 2020 15:19 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/1 "2020-04-07T15:19:15Z")

</div>

Hi  
Just last two week I started to learn node red and I start with very simple things  
I used AND gate with inject number or 80 and numeric.  
I found with condition=\> to the AND gate that the inject button will pass from debug and the other as well but if the inject changed to more 80 then will no output on debug  
would you please explain ow the AND gate operation  
`[{"id":"e2d6afd7.b17cc","type":"inject","z":"d3a7c1fa.6de2c","name":"","topic":"","payload":"82","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["7f28e320.49ef9c"]]}]`

thanks in advance

---

<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:** [7 April 2020 16:12 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/2 "2020-04-07T16:12:15Z")

</div>

You have only exported the inject node, you need to mark all the nodes required to show the problem then export.  
Also tell us which AND get you are using, there are many logic gates available. It is probably node-red-contrib-something.

---

<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:** [7 April 2020 17:55 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/3 "2020-04-07T17:55:58Z")

</div>

Sorry ,please find below 🙂`[{"id":"e2d6afd7.b17cc","type":"inject","z":"d3a7c1fa.6de2c","name":"","topic":"","payload":"82","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":140,"wires":[["7f28e320.49ef9c"]]},{"id":"111037d.ce9eac8","type":"debug","z":"d3a7c1fa.6de2c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":680,"y":240,"wires":[]},{"id":"7f28e320.49ef9c","type":"and-gate","z":"d3a7c1fa.6de2c","name":"AND Gate","rules":[{"t":"gte","v":"80","vt":"num","propertyType":"msg","property":"payload","topic":""},{"t":"gte","v":"80","vt":"str","propertyType":"msg","property":"payload","topic":""},{"t":"eq","v":"80","vt":"str","propertyType":"msg","property":"payload","topic":""}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":true,"x":450,"y":241,"wires":[["111037d.ce9eac8"]]},{"id":"4b03ab62.fcf104","type":"ui_numeric","z":"d3a7c1fa.6de2c","name":"","label":"numeric","tooltip":"","group":"bae91d50.a1df9","order":5,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"","format":"{{value}}","min":0,"max":"100","step":1,"x":180,"y":400,"wires":[["7f28e320.49ef9c"]]},{"id":"68c9c7ad.deb6c8","type":"ui_slider","z":"d3a7c1fa.6de2c","name":"","label":"S1","tooltip":"","group":"bae91d50.a1df9","order":5,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":140,"y":280,"wires":[["7f28e320.49ef9c"]]},{"id":"bae91d50.a1df9","type":"ui_group","z":"","name":"Mustafa","tab":"6af1a82.7e58658","disp":true,"width":"6","collapse":false},{"id":"6af1a82.7e58658","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:** [7 April 2020 18:08 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/4 "2020-04-07T18:08:57Z")

</div>

And the answer to my other question?

---

<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:** [8 April 2020 14:27 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/5 "2020-04-08T14:27:42Z")

</div>

I got it from this link

> **[node-red-contrib-bool-gate](https://flows.nodered.org/node/node-red-contrib-bool-gate)**
>
> Node RED node to include boolean logic gates

---

<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:** [8 April 2020 14:46 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/6 "2020-04-08T14:46:44Z")

</div>

That's what I needed to know, node-red-contrib-bool-gate. Now I can look at your flow.

---

<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:** [8 April 2020 15:13 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/7 "2020-04-08T15:13:21Z")

</div>

If you click on the AND node and then look at the Info tab for it (click the `i` above the right hand pane) you will see instructions on how to use it. They are not very clear I agree but if you look at the first paragraph under the heading Inputs it says  
"topic(mandatory) string  
the topic of the message. This is mandatory because of the node configuration "  
You haven't provided topics for your input messages or for your conditions in the node so it isn't going to work very well.  
I note also that you have selected True Restriction, which according the Info means  
"if checked, the node will output message only if the condition is true"  
So the node will either output nothing or True, but never false.  
Also I don't understand what rules you are trying to use. Since you are testing numbers you should make sure that all the comparisons are of type number, your second and third ones are string (a/z). Looking at the rules you are asking for \>=80 AND \>= 80 AND == 80 which seems an odd thing to be testing.

---

<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:** [8 April 2020 18:53 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/8 "2020-04-08T18:53:26Z")

</div>

Thank you Colin  
it is work now  
I have another question for counters can I post it here or with new topic?

---

<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:** [8 April 2020 20:19 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/9 "2020-04-08T20:19:36Z")

</div>

Glad you got it working.  
If it is a different question then best to start a new thread.

---

<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:** [7 June 2020 20:19 UTC](https://discourse.nodered.org/t/and-gate-experiment/24412/10 "2020-06-07T20:19:52Z")

</div>

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