I'm struggling for hours now.
I use the following code and added an LED Blink for debug purposes,
but only gets one blink and then it hangs (on the serin2).
I have also tried serin.
Using Pic16F877 and have 2 PIR Sensors,
one on SENSORPIN1 and one on SENSORPIN2.
Any ideas?
<code>
Include "Modedefs.bas"
DEFINE OSC 4 ' Set the Xtal frequency
N2400 CON 16780
P0 VAR PORTB.6
P1 VAR PORTB.7
SENSORNUMBER CO N 0
SENSORPIN1 V AR PORTB.4
SENSORPIN2 V AR PORTB.5
LEDPIN VAR PORTD.1
SENSORSTATUS VA R BYTE
DATARECEIVED va r byte
CCP1CON = 0
ADCON1 = 7
Main:
OUTPUT LEDPIN
input SENSORPIN1
input SENSORPIN2
Loop:
IF (SENSORPIN1 = 1) OR (SENSORPIN2 = 1) THEN
SENSORSTATU S = "1"
HIGH LEDPIN
PAUSE 1000
LOW LEDPIN
PAUSE 1000
ENDIF
OUTPUT P0
INPUT P1
LOW P0
' ============ LED BLINK FOR DEBUG PURPOSES =================
HIGH LEDPIN
PAUSE 100
LOW LEDPIN
PAUSE 100
' ================================================== =========
SERIN2 P1, N2400, 10, Loop,[wait("T"),DATARECEIVED]
' ============ LED BLINK FOR DEBUG PURPOSES =================
HIGH LEDPIN
PAUSE 100
LOW LEDPIN
PAUSE 100
' ================================================== =========
if (DATARECEIVED = SENSORNUMBER) then
OUTPUT P1
SEROUT2 P1, N2400, ["R",SENSORSTATUS]
SENSORSTATU S = "0"
endif
' ============ LED BLINK FOR DEBUG PURPOSES =================
HIGH LEDPIN
PAUSE 100
LOW LEDPIN
PAUSE 100
' ================================================== =========
Goto Loop
end
</code>
Thank you!!
koossa
Bookmarks