I am fairly new to PIC's so I would love if I got some help to see if this code would work. I am making a remote control car and I have a receiver and transmitter that both use the 16f84. The four pushbuttons on the transmitter control two motors that are connected to an H-Bridge (on the receiving end) which in turn control both directions for the motors. Can someone tell me if this code is valid for the schematics? Thanks a million...
Both schematics are attached and the code is below...
Transmitter Code
------------------------------------------
INCLUDE "modedefs.bas"
output PORTB.4
start:
'Check if buttons are pressed
if (PORTB.0 = 1) then one
if (PORTB.1 = 1) then two
if (PORTB.2 = 1) then three
if (PORTB.3 = 1) then four
goto start
one:
serout PORTB.4,N2400,["1"]
goto start
two:
serout PORTB.4,N2400,["2"]
goto start
three:
Serout PORTB.4,N2400,["3"]
goto start
four:
serout PORTB.4,N2400,["4"]
goto start
Receiver Code
----------------------
INCLUDE "modedefs.bas"
output PORTA.0
output PORTA.1
output PORTA.2
output PORTA.3
start:
in VAR BYTE
serin PORTB.1,N2400,in
'PORTA.0 receives signal at 2400 baud rate and places
'input at variable in
'Testing serial input
if in == "1" then one
if in == "2" then two
if in == "3" then three
if in == "4" then four
goto start
'Turn on PORTA.x for 100 milliseconds and then turn off (motors)
one:
high PORTA.2
PAUSE 100
low PORTA.2
goto start
two:
high PORTA.3
PAUSE 100
low PORTA.3
goto start
three:
high PORTA.1
PAUSE 100
low PORTA.1
goto start
four:
high PORTA.0
PAUSE 100
low PORTA.0
goto start
--------------------------------
Thanks again!!!
-Mike
Bookmarks