;*****Set up the Constants****
list p=16F84A
include <p16F84A.inc>
COUNT1 = 0x08
COUNT2 = 0x09
;****Set up the port****
org 0x000 ; reset vector
bsf STATUS,RP0 ;Switch to Bank 1
movlw b'00000001' ;Set the Port A pins
movwf TRISA ;bit 1to output, bit 0 to input.
bcf STATUS,RP0 ;Switch back to Bank 0
movlw 0x02 ; Set up our w register with 02h
;****Turn the LED on and off****
Start
xorwf PORTA,1 ; toggle the LED
;****Check if the switch is closed
btfsc PORTA,0 ; test the bit value from PORTA,0
call Delay ; carry on as normal.
; If is a 1, then add an
; extra delay routine
call Delay ; ****Add a delay
;****Check if the switch is still closed
btfsc PORTA,0 ; test the value from PORTA,0
call Delay ;carry on as normal.
;If is a 1, then add an
;extra delay routine
;****Add another delay****
call Delay
;****Now go back to the start of the program
goto Start ;go back to Start and turn LED on again
;****Here is our Subroutine
Delay
Loop1 decfsz COUNT1,1 ;This second loop keeps the L
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1 ;
return
end