۱۴-اردیبهشت-۱۳۹۲, ۱۴:۵۶:۳۰
کد:
$regfile = "m8def.dat"
$crystal = 4000000
Config Portd = Output
Config Portc = Output
Config Pinb.0 = Input
Config Pinb.2 = Input
Dataport Alias Portd
Comm Alias Portc
Dim A As Byte , B As Byte , C As Word , D As Word , N As Byte , M As Byte , V As Byte , T As Byte , Hh As Byte , S As Byte
Dim Aa As Byte , Bb As Byte
Declare Sub Q
Declare Sub W
Declare Sub E
Declare Sub K
Declare Sub X
Do
Call E
Call Q
Call K
If S > 59 Then
N = N + 1
S = 0
End If
If M = 6 Then
V = V + 1
M = 0
N = 0
End If
If T = 6 Then
N = 0
M = 0
T = 0
V = 0
End If
If Pinb.0 = 0 Then
Aa = 0
End If
If Pinb.2 = 0 Thrn
Bb = 0
End If
Loop
'=============================================================================
Sub K
If Aa = 0 Then
If Pinb.0 = 1 Then
Incr S
Call X
Aa = 1
End If
End If
If Bb = 0 Then
If Pinb.2 = 1 Then
N = 0
M = 0
T = 0
V = 0
S = 0
Call X
Bb = 1
End If
End If
End Sub
'========================================================================
Sub E
If N > 9 Then
N = 0
Incr M
If M > 9 Then
M = 0
Incr V
If V > 9 Then
V = 0
Incr T
If T > 9 Then
T = 0
End If
End If
End If
End If
End Sub
'======================================================================
Sub Q
Comm = &B0111 : A = N : Call W
Comm = &B1011 : A = M : Call W
Comm = &B1101 : A = V : Call W
Comm = &B1110 : A = T : Call W
End Sub
'======================================================================
Sub W
Dataport = Lookup(a , Sa)
Waitms 4
Dataport = &H00
End Sub
'========================================================================
Sub X
For Hh = 1 To 2
Call E
Call Q
Next
End Sub
'=============================================================================
Sa:
Data &B00111111 , &B00000110 , &B01011011 , &B01001111
Data &B01100110 , &B01101101 , &B01111101 , &B00000111
Data &B01111111 , &B01101111
![Biggrin Biggrin](https://www.iranled.com/forum/images/smilies2/biggrin.gif)