Sep 4, 2009

PIC16f84 based LED chaser

click on the image to get a clear and large view

This circuit is based on the popular PIC16f84 micro-controller. The port B is used as the output port. 8 LEDs are connected to port B and they glow sequentially one after the other.The delay is between two successive LED glows is 80ms. The glow pattern is LED1-LED8 and LED8-LED1.this process repeats until the power is off.The switch s1 is used to reset the micro-controller.A 4MHz crystal is used for providing clock pulses to the micro-controller.below is the parts list and assembly code.

parts list:
IC1=PIC16f84
R1=5k
R2-R9=330 ohms
Q1=4Mhz cystal oscillator
8LEDs
a 5v battery for power supply

assembly code :

l equ 0xc
k equ 0xd
j equ 0xe
i equ 0xf
;------------------------------------------------------------------------
org 0x000 ;reset vector
goto main

org 0x004;interrupt vector

goto main
;----------------------------------------------------------------------- org 0x005
main
movlw 28
bsf STATUS,5
movwf TRISA
clrf TRISB
bcf STATUS,5
movlw 3
movwf PORTA
movlw 254
movwf PORTB
;-------------------------------------------------------------------
label_setpin
movlw b’00000001’

movwf PORTB
call delay
movlw b’00000010’

movwf PORTB
call delay

movlw b’00000100’

movwf PORTB
call delay

movlw b’00001000’

movwf PORTB
call delay

movlw b’00010000’

movwf PORTB
call delay

movlw b’00100001’

movwf PORTB
call delay

movlw b’10000000’

movwf PORTB
call delay

movlw b’00000001’

movwf PORTB
call delay
goto label_setpin
;-----------------------------------------------------------------------
delay

incf l,1
incf k,1
movlw 104
movwf j
movlw 228
movwf i
call delay_subroutine
return

delay_subroutine
decfsz i,1
goto delay_subroutine
decfsz j,1
goto delay_subroutine
return
END
;------------------------------------------------------------------------

No comments:

Post a Comment