03-16-2014 05:41 PM
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
Solved! Go to Solution.
03-16-2014 05:49 PM
To change the integer output of the digital read to a boolean you can simply use the "Not Equal to 0?" comarpison function.
03-16-2014 05:53 PM
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
03-16-2014 06:10 PM
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.