Hello
I am new to pic programming. I have bought two RF modules and would like to make the link between them using my PIC12f635. I have written the following program for the transmitter:
//PROGRAM START
TRISIO=%011111
w1 VAR word
by var byte
cmcon0=%111
intcon=0
GPIO=0
Include "modedefs.bas"
START:
if gpio.0=1 then ZERO
IF GPIO.1=1 THEN ONE
IF GPIO.2=1 THEN Two
IF GPIO.4=1 THEN FOUR
GOTO START
ZERO:
serout GPIO.5,N2400,["abc",12]
pause 50
LOW GPIO.0
goto start
ONE:
serout GPIO.5,N2400,["abc",56]
pause 50
LOW GPIO.1
goto start
Two:
serout GPIO.5,N2400,["abc",90]
pause 50
LOW GPIO.2
goto start
FOUR:
serout GPIO.5,N2400,["abc",34]
pause 50
LOW GPIO.4
goto start
// program end
I WOULD LIKE TO KNOW HOW I CAN PLACE THE MCU IN POWERDOWN MODE UNTILL I PRESS A BUTTON?
//Receiver Program Start
TRISIO=%011111
pause 50
GPIO=0
pause 50
w1 VAR word
intcon=0
cmcon0=7
Include "modedefs.bas"
pause 50
start:
serin GPIO.2,N2400,100,start,["abc"],w1
pause 50
goto check
goto start
check:
if w1=12 then zero
if w1=56 then one
if w1=90 then four
if w1=34 then five
goto start
zero:
if w1=12 then
toggle gpio.0
pause 2000
else
pause 50
goto check
goto start
endif
one:
if w1=56 then
toggle gpio.1
pause 2000
else
pause 50
goto check
goto start
endif
four:
if w1=90 then
toggle gpio.4
pause 2000
else
pause 50
goto check
goto start
endif
five:
if w1=34 then
toggle gpio.5
pause 2000
else
pause 50
goto check
goto start
endif
//Program End
I WOULD LIKE AN EXPERT ADVISE ON THE RELIABILITY OF THE RECEIVER CODE BEFORE I USE IT TO CONTROL ANY MAINS DEVICE USING AN RELAY OR SCR.
(I am using PICBASICPro)
Thanks in advance for your replies.![]()
Bookmarks