Hi,
If you only want to read it once when it changes you have to know that is has changed and the only way to know that is to read it (or use the Interrupt on change feature) The easiest way is yo keep reading the switches in a loop and compare the current state to the previous state, if they are not the same one or more switches have changed state. Lets say your switches are connected to PortB.0 thru PortB.5, then perhaps something like:
Code:
Switches VAR BYTE
oldState VAR BYTE
TRISB=%00111111 'PortB.0-5 are inputs.
oldState = 0
ReadSwitch:
Switches = PortB & %00111111 'Get 6 low bits.
IF Switches <> oldState THEN ' Has it changed?
GOSUB ActivateTx ' Deal with it.
ENDIF
oldState = Switches ' Remeber current state
Goto ReadSwitch ' Do it again.
ActivateTx:
' Do what needs be done with the transmitter
' and anything else here
RETURN
/Henrik.
Bookmarks