IO operation
Posted: Thu Sep 25, 2014 12:19 am
>this is not a bug as reported by a user
Why-
IO is more complex than just setting a pin.
IO (as the Help files state) sets the direction of the pin then sets the drive level.
so IO(x) = NOT(IO(x))
is converting a pin to an input reading it and then converting to an output and driving it
But during the conversion to an input you are no longer driving it. So you really want to do--
OUT(x) = NOT(IN(x))
As OUT just changes the drive level, and IN reads the pin value whether or not it is being driven (also in the Help files)
Code: Select all
Sub PulseOut (PinNumber as Integer, Length as Integer) 'Length in mS
IO(PinNumber) = NOT(IO(PinNumber)) 'this reversal works
WAIT(Length)
IO(PinNumber) = NOT(IO(PinNumber)) 'this one does not.
End Sub
IO is more complex than just setting a pin.
IO (as the Help files state) sets the direction of the pin then sets the drive level.
so IO(x) = NOT(IO(x))
is converting a pin to an input reading it and then converting to an output and driving it
But during the conversion to an input you are no longer driving it. So you really want to do--
OUT(x) = NOT(IN(x))
As OUT just changes the drive level, and IN reads the pin value whether or not it is being driven (also in the Help files)