;TITLE: AVAILABLE PARKING SPACE
;PIC TYPE: 16F84A
;OSCILLATOR SPEED: 4 MHz
list p=16F84A
#include "P16F84A.INC"
errorlevel -302, -207
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;***********PORT A: ALL INPUT**********
#DEFINE EXIT PORTA,3
#DEFINE ENTR PORTA,4
;**********PORT B: ALL OUTPUT**********
#DEFINE LED1 PORTB,0
#DEFINE LED2 PORTB,1
#DEFINE LED3 PORTB,2
#DEFINE LED4 PORTB,3
#DEFINE LED5 PORTB,4
#DEFINE LED6 PORTB,5
#DEFINE LED7 PORTB,6
#DEFINE PAO STATUS,5
DRAWER1 equ 30H
;**********MAIN PROGRAM STARTS HERE**********
org 00H
INIT clrf PORTA
clrf PORTB
bsf STATUS,RP0;;;PA0 [B]changed this[/B]
movlw b'00011111'
movwf TRISA
movlw b'00000000'
movwf TRISB
bcf STATUS,RP0;;;PAO [B]changed this[/B]
;*********START*********
START:
movlw 04H
movwf DRAWER1
CHECK btfsc ENTR; [B]the check of A3 and A4 works OK[/B]
goto NEXT
decf DRAWER1,1
goto DISPLAY
NEXT btfsc EXIT
goto CHECK
incf DRAWER1,1
goto DISPLAY
goto CHECK
DISPLAY movlw 04H
subwf DRAWER1,0
btfss STATUS,Z
goto NO3
movlw H'99'
movwf PORTB
NO3 movlw 03H
subwf DRAWER1,0
btfss STATUS,Z
goto NO2
movlw H'B0'
movwf PORTB
NO2 movlw 02H
subwf DRAWER1,0
btfss STATUS,Z
goto NO1
movlw H'A4'
movwf PORTB
NO1 movlw 01H
subwf DRAWER1,0
btfss STATUS,Z
goto NO0
movlw H'F9'
movwf PORTB
NO0 movlw 00H ;[B]This loops forever[/B]
subwf DRAWER1,0
btfss STATUS,Z
goto NO0 ;[B].....................................[/B]
movlw H'C0'
movwf PORTB
goto START
end