You are on page 1of 1

#include <p18f4520.

inc>

;Inputs
TEMP EQU RB0
MOTION EQU RB1
DOOR EQU RB2
SENSOR EQU PORTB

;Ouputs
; FanOUT RC0
; LEDMOTION RC1
; LEDDOOR RC2

ORG 2AH

main
SETF TRISB
CLRF TRISC
CLRF PORTC

TempSensing
BTFSS SENSOR,TEMP
GOTO TempLow
BSF PORTC,0 ; Turn on the fan
GOTO MotionSensing
TempLow
BCF PORTC,0 ; Turn off the fan

MotionSensing
BTFSS SENSOR,MOTION
GOTO Undetected
BSF PORTC,1 ; Turn on the LED motion
GOTO DoorSensing
Undetected
BCF PORTC,1 ; Turn off the LED MOTION

DoorSensing
BTFSS SENSOR,DOOR
GOTO DoorClose
BSF PORTC,2 ; Turn on the LED for Door
GOTO TempSensing
DoorClose
BCF PORTC,2 ; Turn off the LED for Door
GOTO TempSensing

END

You might also like