My program
Code:
Xtal=4
Dim DG As Byte
Dim DIGIT As Byte
Dim n As Word
Dim NUMB As Word
Dim countt As Byte
Dim dg1 As Byte
Dim dg2 As Byte
Dim DG3 As Byte
Dim dg4 As Byte
Symbol pin =PORTA.2
ADCON1=%10000000
ADCON0=%01000011
TRISA=%01111101
TRISB=0
TRISC=%00010000
ANSELH=%00000001
ANSEL=%00000001
CM1CON0=0
CM2CON0=0
VRCON=0
main:
NUMB=Counter pin,1000
n=NUMB
GoSub DISPLAY
GoSub DIGITCALC
GoTo main
DISPLAY: ;breaking digits into 4 display
For countt=0 To 99
PORTB=dg1
PORTC.3=0
DelayUS 100
PORTC.3=1
PORTB=dg2
PORTC.2=0
DelayUS 100
PORTC.2=1
PORTB=DG3
PORTC.1=0
DelayUS 100
PORTC.1=1
PORTB=dg4
PORTC.0=0
DelayUS 100
PORTC.0=1
Next countt
Return
'_________________________________________________ _________________________
DIGITCALC: ;data to each display ones,tens,hundred,thousands
DIGIT=0
LP1:
If n<1000 Then DS1
n=N-1000
DIGIT=DIGIT+1
GoTo LP1
DS1:
GoSub FND
dg1=DG
DIGIT=0
LP2:
If n<100 Then DS2
n=N-100
DIGIT=DIGIT+1
GoTo LP2
DS2:
GoSub FND
dg2=DG
DIGIT=0
LP3:
If n<10 Then DS3
n=N-10
DIGIT=DIGIT+1
GoTo LP3
DS3:
GoSub FND
DG3=DG
DIGIT=n
GoSub FND
dg4=DG
Return
'___________________________________________________________________________
FND: ;data for each segment.
FND0: ;zero
If DIGIT>0 Then FND1
DG=%00000011
GoTo FNDEND
FND1: ;one
If DIGIT>1 Then FND2
DG=%10011111
GoTo FNDEND
FND2: ;two
If DIGIT>2 Then FND3
DG=%00100101
GoTo FNDEND
FND3: ;three
If DIGIT>3 Then FND4
DG=%00001101
GoTo FNDEND
FND4: ;four
If DIGIT>4 Then FND5
DG=%10011001
GoTo FNDEND
FND5: ;five
If DIGIT>5 Then FND6
DG=%01001001
GoTo FNDEND
FND6: ;six
If DIGIT>6 Then FND7
DG=%01000001
GoTo FNDEND
FND7:
If DIGIT>7 Then FND8 ;seven
DG=%00011111
GoTo FNDEND
FND8: ;eight
If DIGIT>8 Then FND9
DG=%00000001
GoTo FNDEND
FND9:
DG=%00011001 ;nine
FNDEND:
Return