کد:
$regfile = "M8DEF.DAT"
$crystal = 8000000
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
Readeeprom Ns , 17
Readeeprom Np , 25
If Ns < 1 Then : Ns = 1 : Writeeeprom Ns , 17 : End If
If Np < 1 Then : Np = 1 : Writeeeprom Np , 25 : End If
Np = Np + 1
Writeeeprom Np , 25
Config Portb.1 = Output : Reset Portb.1
Config Portd.0 = Output ':Reset Portd.0
Config Portd.0 = Output
Dim Secr As Byte : Secr = 0
Disable Int1
Dim Lcdled As Byte : Readeeprom Lcdled , 15
Dim Decimal As Byte : Readeeprom Decimal , 10
Dim Lenght As Single : Readeeprom Lenght , 1
Dim Show As Byte : Readeeprom Show , 30
If Show > 1 Then
Show = 1
Writeeeprom Show , 30
End If
If Show < 0 Then
Show = 0
Writeeeprom Show , 30
End If
If Lcdled > 1 Then
Lenght = 1
Writeeeprom Lcdled , 15
End If
If Lenght < 0 Then
Lenght = 0
Writeeeprom Lcdled , 15
End If
If Lenght > 100 Then
Lenght = 100
Writeeeprom Lenght , 1
End If
If Lenght < 1 Then
Lenght = 1
Writeeeprom Lenght , 1
End If
If Decimal > 9 Then
Decimal = 9
Writeeeprom Decimal , 10
End If
If Decimal < 1 Then
Decimal = 1
Writeeeprom Decimal , 10
End If
Config Portb.0 = Input ' : Portb.0 = 0
Config Portd.7 = Input ' : Portd.7 = 0
Config Portd.4 = Input ': Portd.4 = 0
Config Portd.3 = Input ' : Portd.3 = 0
Config Adc = Single , Prescaler = Auto
Config Debounce = 25
Cursor Off
Enable Interrupts
Cls
Config Timer0 = Counter , Edge = Rising
Config Int1 = Change
Config Timer1 = Timer , Prescale = 8
Enable Timer1
Enable Ovf1
On Ovf1 T1
Waitms 500
A:
Readeeprom Lcdled , 15
If Lcdled = 1 Then
Set Portb.1
Else
Reset Portb.0
End If
Stop Timer1
Timer1 = 0
Tcnt0 = 0
A = 0
B = 0
Locate 1 , 1
Lcd "STOPWATCH READY"
Do
If Pind.4 = 1 Then
Start Timer1
Cls
Enable Int1
On Int1 Ee
'Ns = Ns + 1
'Writeeeprom Ns , 17
'Sound Pind.0 , 10 , 500
waitms 500
jmp B
End If
Loop
If Pind.3 = 1 Then
Secr = Secr + 1
Waitms 200
End If
Debounce Pind.7 , 1 , Ne1
'On Int0 B
'Do
'Loop
If Tcnt0 = 1 Then
Start Timer1
Cls
Enable Int1
'Ns = Ns + 1
'Writeeeprom Ns , 17
Sound Pind.0 , 70 , 500
jmp B
Else
jmp A
End If
B:
If Tcnt0 = 2 Then
Stop Timer1
A = B * 65536
A = A + Timer1
A = A / 1000000
Readeeprom Decimal , 10
Readeeprom Lenght , 1
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 , 70 , 500
jmp C
Elseif Tcnt0 = 1 Then
A = B * 65536
A = A / 1000000
Readeeprom Decimal , 10
Readeeprom Lenght , 1
Readeeprom Show , 30
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 B
End If
Return
C:
Do
If Tcnt0 = 3 Then
Tcnt0 = 0
Cls
JMP A
End If
Loop
T1:
Timer1 = 0
Incr B
Return
Ee:
Tcnt0 = 2
'Stop Timer1
'A = B * 65536
'A = A + Timer1
'A = A / 1000000
'Locate 1 , 1
'Lcd Fusing(a , "##.######")
'Lcd " SecC "
'Tcnt0 = Tcnt0 + 1
'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 "Length : "
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 , 500 '@@@@@@@@@@@
jmp ne3
Return
Ne3: '#############################
Readeeprom Lcdled , 15
Cls
Do
Home
Lcd "Lcd Light: "
If Lcdled = 1 Then : Lcd "True" : Else : Lcd "False" : End If
Lcd " "
Debounce Pind.7 , 1 , Goback3
If Pind.4 = 1 Then
Lcdled = 1
Waitms 200
End If
If Pind.3 = 1 Then
Lcdled = 0
Waitms 200
End If
Loop
Return
Goback3:
Writeeeprom Lcdled , 15
Readeeprom Lcdled , 15
If Lcdled = 1 Then
Set Portb.1
Else
Reset Portb.0
End If
Tcnt0 = 0
If Secr = 7 Then
Secr = 0
Sound Pind.0 , 70 , 500
End If
Sound Pind.0 , 70 , 300 '@@@@@@@@@@@
jmp O
Return