Hi Henrik
Thanks for the code, Set up your example and it works fine, I have to read each Switch separately and then send individual info on each switch level when it changes.
I have done a small sample using your code but, I know that there will be different variables with the state of the switches eg: �1101 or 0100
I have put a sample for an individual bit too look at in my code and then print on LCD when it matches but, I know that there can be many different states of the bits present at any time.
Is there a better and simpler way that I can look at an individual bits condition and react on it?
Please have a look at my piece of code to better understand what I mean
Thanks for the help!
Craig
Switches VAR BYTE
oldState VAR BYTE
Oldstate = 0
ReadSwitch:
Switches = PORTA & 111 ' Get 5 low bits.
Print At 1,1, Bin Switches
If Switches <> Oldstate Then ' Has it changed?
GoSub ActivateTx ' Deal with it.
EndIf
Oldstate = Switches ' Remeber current state
GoTo ReadSwitch ' Do it again.
ActivateTx:
Print At 2,1, "BIT= "
If PORTA.1 = 0 Then ' When Bit 1 Changes State Print "0" on LCD
Print At 2,7, "0"
EndIf
If PORTA.2 = 0 Then ' When Bit 2 Changes State Print "1" on LCD
Print At 2,7, "1"
EndIf
If PORTA.4 = 0 Then ' When Bit 4 Changes State Print "2" on LCD
Print At 2,7, "2"
EndIf
Return
End
Bookmarks