| |
;set up
SETB RP0 ;set register page 1
MOV TRISA,#00000000B ;set porta i/o 0=output
CLRB RP0 ;set register page 0
;test the light value, and switch if the light levels are low (beam broken)
SETB PORTA.0 ;discharge beam cap by setting pin high (+5V)
CALL MINIPAUSE ;give the capacitor a chance to *discharge*,
;before we measure its *recharge* time!
SETB RP0 ;change pin to input, therefore allowing cap to recharge
MOV TRISA,#00000001B ;be careful not to mess up the i/o settings
CLR RP0 ;on your other pins!
PAUSE ;wait for a bit (adjust wait time to your application)
CLR C1 ;set C1 as zero
PAUSELOOP
DJNZ C1,PAUSELOOP ;decrease c1 (-1) then loop until zero
;if beam cap not recharged by now then no light therefore beam broken
JB PORTA.0,NOLIGHT
;if light levels are high then...
|
|  |