کد:
$regfile = "M8def.dat"
$crystal = 8000000
Config Portb.1 = Output
Cls : Cursor Off : Home
Dim W As Byte : W = 20
Deflcdchar 0 , 32 , 32 , 21 , 21 , 31 , 32 , 32 , 32 : Deflcdchar 1 , 32 , 32 , 4 , 4 , 31 , 32 , 20 , 8 : Deflcdchar 2 , 32 , 32 , 32 , 32 , 25 , 10 , 4 , 32 : Deflcdchar 3 , 32 , 32 , 32 , 32 , 7 , 4 , 4 , 24 : Deflcdchar 4 , 32 , 32 , 2 , 5 , 29 , 2 , 32 , 32 : Deflcdchar 5 , 32 , 32 , 28 , 2 , 31 , 32 , 32 , 32 : Deflcdchar 6 , 10 , 32 , 14 , 10 , 31 , 32 , 32 , 32 : Deflcdchar 7 , 10 , 32 , 14 , 10 , 15 , 2 , 18 , 30 : Home : Lcd Chr(7) : Lcd Chr(6) : Lcd Chr(5) : Lcd Chr(4) : Lcd " " : Lcd Chr(3) : Lcd Chr(2) : Lcd Chr(1) : Lcd Chr(0) : Locate 2 , 1 : Lcd "MADE BY SMNSOFT"
Do
Toggle Portb.1
Waitms 200
W = W - 1
If W = 1 Then : Exit Do : End If
Loop
Cls
O:
Dim Ma As Byte : Dim A As Single : Dim A1 As Single : Dim B As Word : Dim Aa As Single : Dim Decimal1 As Single : Dim Ns As Integer : Dim Np As Integer : Dim Secr As Byte : Secr = 0
Dim Lcdled As Byte : Readeeprom Lcdled , 16 : Waitms 50
Dim Decimal As Byte : Readeeprom Decimal , 10 : Waitms 50
Dim Lenght As Single : Readeeprom Lenght , 1 : Waitms 50
Dim Show As Byte : Readeeprom Show , 30 : Waitms 50
Readeeprom Ns , 17 : Waitms 50 : Readeeprom Np , 25 : Waitms 50
If Ns < 1 Then : Ns = 1 : Writeeeprom Ns , 17 : End If
If Np < 1 Then : Np = 1 : Writeeeprom Np , 25 : End If
Config Portd.0 = Output
Config Portb.0 = Input : Config Portd.7 = Input : Config Portd.4 = Input : Config Portd.3 = Input
Config Debounce = 25
Config Timer0 = Counter , Edge = Rising
Config Int0 = Change
Config Timer1 = Timer , Prescale = 8
Readeeprom Lcdled , 3 : Waitms 50
If Show > 1 Then : Show = 1 : Writeeeprom Show , 30 : Waitms 50 : End If : If Show < 0 Then : Show = 0 : Writeeeprom Show , 30 : Waitms 50 : End If
If Lcdled > 1 Then : Lenght = 1 : Writeeeprom Lcdled , 16 : Waitms 50 : End If
If Lenght < 0 Then : Lenght = 0 : Writeeeprom Lcdled , 16 : Waitms 50 : End If : If Lenght > 100 Then : Lenght = 100 : Writeeeprom Lenght , 1 : Waitms 50 : End If : If Lenght < 1 Then : Lenght = 1 : Writeeeprom Lenght , 1 : Waitms 50 : End If
If Decimal > 9 Then : Decimal = 9 : Writeeeprom Decimal , 10 : Waitms 50 : End If : If Decimal < 1 Then : Decimal = 1 : Writeeeprom Decimal , 10 : Waitms 50 : End If
Enable Int0
Enable Interrupts
On Int0 Ee
Enable Timer1
Enable Ovf1
On Ovf1 T1
Waitms 500
A:
Readeeprom Lcdled , 16 : Waitms 50
If Lcdled = 1 Then : Pind.1 = 1 : Else : Pind.1 = 0 : End If
Stop Timer1
Timer1 = 0
Tcnt0 = 0
A = 0
B = 0
Home : Lcd "STOPWATCH READY"
Readeeprom Decimal , 10 : Waitms 50
Readeeprom Lenght , 1 : Waitms 50
Readeeprom Show , 30 : Waitms 50
Do
Debounce Pind.7 , 1 , Ne1
If Pind.3 = 1 Then
Tcnt0 = 1
Start Timer1
Cls
Sound Pind.0 , 20 , 300 '**Should be 70
'Waitms 50
jmp B
End If
Loop
B:
Cls : Home ': Lcd "WAIT..."
Readeeprom Decimal , 10 : Waitms 50
Readeeprom Lenght , 1 : Waitms 50
Tcnt0 = 1
Stopit:
If Tcnt0 = 255 Then
Stop Timer1
Tcnt0 = 20
A = B * 65536
A = A + Timer1
A = A / 1000000
A1 = A ^ 2
A1 = A1 * 0.5
Decimal1 = Lenght / 100
A1 = Decimal1 / A1
Cls
If Decimal = 9 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#########") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#########") : End If
If Decimal = 8 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.########") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.########") : End If
If Decimal = 7 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#######") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#######") : End If
If Decimal = 6 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.######") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.######") : End If
If Decimal = 5 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#####") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#####") : End If
If Decimal = 4 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.####") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.####") : End If
If Decimal = 3 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.###") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.###") : End If
If Decimal = 2 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.##") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.##") : End If
If Decimal = 1 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#") : End If
If Decimal = 0 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.") : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.") : End If
Sound Pind.0 , 20 , 300
jmp C
Else
A = B * 65536
A = A / 1000000
If Show = 1 Then : A1 = A ^ 2 : A1 = A1 * 0.5 : Decimal1 = Lenght / 100 : A1 = Decimal1 / A1 : End If
If Decimal = 9 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#########") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#########") : End If : End If
If Decimal = 8 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.########") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.########") : End If : End If
If Decimal = 7 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#######") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#######") : End If : End If
If Decimal = 6 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.######") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.######") : End If : End If
If Decimal = 5 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#####") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#####") : End If : End If
If Decimal = 4 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.####") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.####") : End If : End If
If Decimal = 3 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.###") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.###") : End If : End If
If Decimal = 2 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.##") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.##") : End If : End If
If Decimal = 1 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#") : End If : End If
If Decimal = 0 Then : Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.") : If Show = 1 Then : Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.") : End If : End If
jmp Stopit
End If
Return
C:
Do
If Pind.7 = 1 Then
Sound Pind.0 , 70 , 500
Cls
jmp o
End If
Loop
T1:
Timer1 = 0
Incr B
Return
Ee:
'Stop Timer1
'A = B * 65536
'A = A + Timer1
'A = A / 1000000
'Locate 1 , 1
'Lcd Fusing(a , "##.######")
'Lcd " SecC "
Tcnt0 = 255
'jmp c
Return
Ne1:
Sound Pind.0 , 70 , 500 '################################
Readeeprom Decimal , 10
Cls
Do
Home
Lcd "Decimal : "
Lcd Decimal
Lcd " "
Debounce Pind.7 , 1 , Goback1
If Pind.4 = 1 Then
If Decimal < 9 Then
Decimal = Decimal + 1
Waitms 200
Else
Decimal = 9
End If
End If
If Pind.3 = 1 Then
If Decimal > 1 Then
Decimal = Decimal - 1
Waitms 200
Else
Decimal = 0
End If
End If
Loop
Return
Goback1:
Writeeeprom Decimal , 10
Tcnt0 = 0
Sound Pind.0 , 70 , 500 '@@@@@@@@@@@
jmp ne2
Return
Ne2: '#############################
Readeeprom Lenght , 1
Cls
Do
Home
Lcd "Height : "
Lcd Fusing(lenght , "##.#")
Lcd " "
Debounce Pind.7 , 1 , Goback2
If Pind.4 = 1 Then
Lenght = Lenght + 0.1
Waitms 200
End If
If Pind.3 = 1 Then
Lenght = Lenght - 0.1
Waitms 200
End If
Loop
Return
Goback2:
Writeeeprom Lenght , 1
Tcnt0 = 0
Sound Pind.0 , 70 , 500 '@@@@@@@@@@@
jmp ne4
Return
Ne4: '#############################
Readeeprom Show , 30
Cls
Do
Home
Lcd "Shwo accelerate:"
Locate 2 , 1
If Show = 1 Then : Lcd "True" : Else : Lcd "False" : End If
Lcd " "
Debounce Pind.7 , 1 , Goback4
If Pind.4 = 1 Then
Show = 1
Waitms 200
End If
If Pind.3 = 1 Then
Show = 0
Waitms 200
End If
Loop
Goback4:
Writeeeprom Show , 30
Tcnt0 = 0
Sound Pind.0 , 70 , 300
Cls '@@@@@@@@@@@
jmp O
Return
Return