LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Confused by digital input

Solved!
Go to solution

I'm trying to read a switch, invert its value, and connect to an AND gate - I thought this would be easy. I'm getting an error that the data types are incompatible, the source being an unsigned byte and the sink being a boolean. I thought that using the Digital Read Pin would return a binary (although in using Digital Write Pin I had to convert the binary to (0,1) before the compiler was happy.

Can someone show me the best (and/or perhaps the easy) solution to my dilemma? I suppose I could compare the input to zero and use the boolean output of that as my AND gate input, but that seems awkward.

Thanks very much in advance.

John

0 Kudos
Message 1 of 4
(3,689 Views)

To change the integer output of the digital read to a boolean you can simply use the "Not Equal to 0?" comarpison function.

Message 2 of 4
(3,184 Views)

To answer my own question, I used the comparison gate NotEqual 0 to invert a digital input, but is that the best solution? Would others be happy with this outcome? It seems a bit cheesy to me. (and I've done some pretty cheesy coding to get stuff to work before.)

Thanks

John

0 Kudos
Message 3 of 4
(3,184 Views)
Solution
Accepted by topic author JohnGriswold

That is the best solution.  I can't think of any alternatives.  You could make a wrapper VI for the Digital Read Pin function that outputs a boolean.

Message 4 of 4
(3,184 Views)