serial wireless receiver code
Ok, this should work. Ingest the code, understand the manchester encoding method.
And your other program only turned LEDs on, it never turned them off. And it never cleared B0.
'RECEIVER CODE
DEFINE OSC 20 '20Mhz Oscillator was used
Include "modedefs.bas" ' Include serial modes
ADCON0 = 0 : ADCON1 = 7 'AD MODULE OFF & CONSUMES NO CURRENT
CMCON = 7 'COMPARATORS OFF
TRISA = $00 : TRISB = $FF 'all porta is outputs, all portb is inputs
B0 var byte
'testing led outputs
porta.0 = 1 : pause 200 : porta.0 = 0
porta.1 = 1 : pause 200 : porta.1 = 0
porta.2 = 1 : pause 200 : porta.2 = 0
porta.3 = 1 : pause 200 : porta.3 = 0
start:
B0 = 0 'empty B0 because the program doesn't
serin PORTB.3,n2400,[B0] 'if n2400 doesn't work, try t2400
if B0 = $aa then training 'manchester encoded $f
if B0 = $55 then training 'manchester encoded $0
if B0 = $56 then led1toggle 'manchester encoded $1
if B0 = $59 then led2toggle 'manchester encoded $2
if B0 = $5A then led3toggle 'manchester encoded $3
if B0 = $65 then led4toggle 'manchester encoded $4
if B0 = $66 then ledson 'manchester encoded $5
if B0 = $69 then ledsoff 'manchester encoded $6
if B0 = $6A then ledswing 'manchester encoded $7
'still have $8-$e free to use
goto start
led1toggle:
if porta.0 = 1 then
porta.0 = 0
else
porta.0 = 1
endif
goto start
led2toggle:
if porta.1 = 1 then
porta.1 = 0
else
porta.1 = 1
endif
goto start
led3toggle:
if porta.2 = 1 then
porta.2 = 0
else
porta.2 = 1
endif
goto start
led4toggle:
if porta.3 = 1 then
porta.3 = 0
else
porta.3 = 1
endif
goto start
ledson:
porta.0 = 1 : porta.1 = 1 : porta.2 = 1 : porta.3 = 1
goto start
ledsoff:
porta.0 = 0 : porta.1 = 0 : porta.2 = 0 : porta.3 = 0
goto start
ledswing:
porta.0 = 1 : pause 10 : porta.0 = 0
porta.1 = 1 : pause 10 : porta.1 = 0
porta.2 = 1 : pause 10 : porta.2 = 0
porta.3 = 1 : pause 10 : porta.3 = 0
goto start
end
Redo your transmitter code to match the receiver code. Put a few buttons on it to transmit the codes above needed to turn your leds on and off, etc.
Do you have a couple of buttons on the transmitter or is it just a free running PIC without any outside input?
JDG