Running Lights
With Up Down Counter
Circuit :  Milardo de Guzman, Philippines
Email  :  milardo_dg@yahoo.com


Description
Milardo continues his work with Microcontrollers. This circuit is for an Atmel Microcontroller type 89C2C51. It is interfaced to a 7 segment display and programmed to count up and down. From his research Milardo has designed a new circuit and called it "3-Digit Display Scoreboard with 4x4 Keypad Matrix".



Notes
The 7 segment display uses and each LED use series limiting resistors of 220 ohms.

This 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.



Assembler Code
			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.
The source code for the 8051 microcontroller is available below as an hex file.

Download Hex code

Download Assembler Code

Atmel Programmers
To program the microcontroller you need suitable development software and a suitable Atmel programmer as shown in the link below. Either the assembler code or hex code is downloaded and loaded into the development software. Then use the development software to program the microcontroller.

Atmel Programmer

A typical Atmel programmer is shown below. Atmel programmers are available from many sources, a search on google should reveal a supplier near you.

Circuit Exchange International Return to Microcontroller Circuits http://www.zen22142.zen.co.uk