Getting Exact Pin Inputs

Hello, I want to get input from that exact pin so that in node-red I can compare the value of it.

so, If I'm using Rpi & for i.e pin 32 and 33 I want value from it with identification of that pin.

(like pin 32--> true and pin 33--> false)

How can I get this so further sequences can be done according to their values?

because if I get first pin 33 value my comparator will not understand which pin signal is?

I don't understand what you mean, each gpio input node specifies the pin, so there is no confusion as to which pin it is coming from that node. If you have two pins they will come down different wires so again there is no confusion.
Also note that the gpio pin sets the topic to tell you which pin it is, so if you were to use a Join node to comine them then you can identify them by the topics.

If that doesn't help then explain more about what you are doing.

1 Like

Just to further iterate on what @Colin wrote. When you get a message from a gpio node it will include a topic like this:
image
If you connect the output from two gpio nodes to one function node you will have to save the input value as the function node will only ever operate on the message it just received.
So to compare values coming from two different nodes to one function node you will have to use context storage which you can read about here:

This explains the general concepts but there is also a link at the bottom which links to how to use this in a function node.
Work through this.
Once you have grasped this you can than do the following in a function node:

  • if topic is pin 33 -> save to context as 33 and get the stored value for 32
  • if topic is pin 32 -> save to context as 32 and get the stored value for 33
  • compare the incoming value to the other value you retrieved from context with an if else statement based on your needs
  • return a output message based on this if condition

To write this code you will need the following JavaScript and nodered skills:

  • working with context in functions:
  • if conditions:

Feel free to ask if you get stuck applying those concepts.

2 Likes

ohh! got it. my bad I didn't see the pin number on topic side.

Thanks @Colin.

1 Like

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