When do you turn off the leds that you turn on initially?
My thinking is that while keeping the switch on for the momentary relay to stay on the data being branch would be the same so the relay would stay on. When I release the switch then the data being branched changes so the relay would turn off. Is this correct?
what value is Keydata if no key pushed ??? good question !
The value of Keydata is 0 if no key is pressed: here is how I've set that,
if keyin = nokey then keydata = %00000000
Thank you for your help.
This is what I am using to send to the relay board
define osc 4
INCLUDE "MODEDEFS.BAS"
CMCON = 7
serpin var porta.3
nokey con %11111111
preamble con %01010101
synch con 254
keyin var portb
keydata var byte
trisb = %11111111
trisa = %00010111
key1 VAR PORTB.0
key2 VAR PORTB.1
key3 VAR PORTB.2
key4 VAR PORTB.3
key5 VAR PORTB.4
key6 VAR PORTB.5
key7 VAR PORTB.6
na VAR PORTB.7
findkey:
clear
pause 50
if key1 = 0 then sw1
if key2 = 0 then sw2
if key3 = 0 then sw3
if key4 = 0 then sw4
if key5 = 0 then sw5
if key6 = 0 then sw6
if key7 = 0 then sw7
if key8 = 0 then sw8
goto findkey
sw1:
keydata = 1
goto transmit
sw2:
keydata = 2
goto transmit
sw3:
keydata = 3
goto transmit
sw4:
keydata = 4
goto transmit
sw5:
keydata = 5
goto dout
sw6:
keydata = 6
goto transmit
sw7:
keydata = 7
goto transmit
sw8:
keydata = 8
goto transmit
transmit:
serout serpin,N2400,[preamble,synch,keydata]
pause 50
if keyin = nokey then keydata = %00000000
goto findkey
end