Wednesday, October 10, 2007

2 INPUT(PHOTORESISTER&INFRARED






Each input has its individual output. The green LED is for the photoresister and the Blue for the infrared. The relationship created between the two is something like a "system override". This is created purely by the prolonging of the pause in the coding. When the infrared sensor is tripped the photoresistor stops for 6 sec as seen in the coding below. After the "UPDATE_DISPLAY_INFARED_A:" has finished sensing whatever tripped it then the photoresister has the availability to sense shading or light again.

The pause which is longer in the infrared coding "UPDATE_DISPLAY_INFARED_A:" can be cut shorter and the coding in the "UPDATE_DISPLAY_A:" could be prolonged to create the reverse effect. The utilization of the pause creates an intended dominance of one sensor over the other.


Coding:

' {$STAMP BS2}
' {$PBASIC 2.5}



PIR PIN 0
PHOTO VAR Word
INFARED VAR Word

DEBUG "!BOOOM", CR

MAIN:
DO
GOSUB GET_RC_TIME_PHOTORESISTOR
GOSUB GET_FREQOUT_INFARED
GOSUB DELAY_PHOTORESISTOR
GOSUB DELAY_INFARED
GOSUB UPDATE_DISPLAY_A
GOSUB UPDATE_DISPLAY_INFARED_A
LOOP







GET_RC_TIME_PHOTORESISTOR:
HIGH 2
PAUSE 100
RCTIME 2, 2, PHOTO
DEBUG DEC PHOTO, CR
RETURN

GET_FREQOUT_INFARED:
HIGH 3
FREQOUT 3,2,38500
INFARED=IN0
DEBUG DEC INFARED, CR
RETURN

DELAY_PHOTORESISTOR:
PAUSE PHOTO
RETURN

DELAY_INFARED:
PAUSE INFARED
RETURN

UPDATE_DISPLAY_A:
IF PHOTO=1THEN
HIGH 14
DEBUG "TRIPZORD photo", CR
ENDIF
PAUSE 100
LOW 14
RETURN


UPDATE_DISPLAY_INFARED_A:
IF INFARED=1 THEN
HIGH 13
DEBUG "TRIPPED infrared", CR
PAUSE 6000
LOW 13
PAUSE 100
ENDIF
RETURN

Labels:


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?