Circuit : Milardo de Guzman, Philippines ![]()
Email : milardo_dg@yahoo.com
NotesThis circuit will count from 0 to 9 and count back from 9 to 0. While counting, the eight LED will alternately turn-on and turn-off. Just like a Johnson Counter with additional sequence.
Keil microvision was used to assemble the program. The code was simulated in Proteus ISIS.
ORG 00H SJMP START START: MOV P3,#00H MOV P3,#0FFH LOOP: MOV P3,#00000000B CALL DELAY MOV P3,#10000000B CALL DELAY MOV P3,#01000000B CALL DELAY MOV P3,#00100000B CALL DELAY MOV P3,#00010000B CALL DELAY MOV P3,#00001000B CALL DELAY MOV P3,#00000100B CALL DELAY MOV P3,#00000010B CALL DELAY MOV P3,#00000001B CALL DELAY MOV P3,#0FFH CALL DELAY MOV P3,#11111110B CALL DELAY MOV P3,#11111101B CALL DELAY MOV P3,#11111011B CALL DELAY MOV P3,#11110111B CALL DELAY MOV P3,#11101111B CALL DELAY MOV P3,#11011111B CALL DELAY MOV P3,#10111111B CALL DELAY MOV P3,#01111111B CALL DELAY SJMP LOOP DELAY: MOV R2,#04 HERE3: MOV R1,#180 HERE2: MOV R0,#255 HERE1: DJNZ R0,HERE1 DJNZ R1,HERE2 DJNZ R2,HERE3 RET END
The delays are implemented by decrementing registers R2, R1 and R0. For a faster count sequence, change the value of R2, R1 and R0. The code can be modified to suit your own requirements.
Source Code for the Microcontroller.
A typical Atmel programmer is shown above. Atmel programmers are available from many sources, a search on google should reveal a supplier near you. The lever moves the contacts on the IC socket to allow insertion of the PIC. This is known as a "ZIF" socket or Zero Insertion Force socket, which ensures that no IC pins will be bent.
| Circuit Exchange International | Return to Microcontroller Circuits | https://www.cxi1.co.uk |