درواقع برنامم اینه البته بازم میگم کریستال از بیرون وصل نکردم آیا حتما لازمه
کد:
$regfile = "M8DEF.DAT"
$crystal = 12000000
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , Rs = Portc.0 , E = Portc.1
Config Lcd = 16 * 2
Config Kbd = Portb 'keyboard
Config Portd = Output 'motor and cuter
Config Pind.2 = Input 'sensor
Config Pind.3 = Input 'sensorcuter
Dim A As Byte , B As String * 5 , B1 As String * 5 'a=key,b=calkey,b1=megdar koli varede
'Dim Cuter As Bit , Motor As Bit , Sensorcuter As Bit 'portd.0=cuter,portd.1=motor,pind.3=sensorcuter
Dim Tool1 As Word , Tool2 As Word , Tedad1 As Word , Tedad2 As Word 'tool1=tool2=tool,tedad1=tedad2=tedad
Dim C As Bit , C1 As Bit , C2 As Bit , C3 As Bit 'c=0=tool,c=1=tedad,c1=0=etelat vared nashode,c1=1=etelat vared shode,c2=1=cutter da hale kare,c2=0=karw cutter tamam shode,c3=1=motor dar hale kare,c3=0=motor istada
Dim Met1 As Word 'met1=megdar palsha
Const Met = 1 'met=megdar pals baraye 1 metr
Cuter Alias Portd.0 : Motor Alias Portd.1 : Sensorcuter Alias Pind.3 : Sensor Alias Pind.2 'portd.0=cuter,portd.1=motor,pind.3=sensorcuter
Main:
Met1 = 0
C1 = 0
C2 = 0
C3 = 1
Goto Dis
Dis: 'nemayesh va gereftan megdar
Tool:
Cls 'neveshtan ebarat tol
Lcd "tool:" 'neveshtan ebarat tool
C = 0
B1 = "" 'amal tool
Locate 2 , 1
Goto Valuekeylcd 'gereften megdar tol
Tedad: 'neveshtan ebarat tedad
Cls
Lcd "tedad:" 'neveshtan ebarat tedad
C = 1
B1 = "" 'amal tedad
Locate 2 , 1
Goto Valuekeylcd 'gereften megdar tedad
Disp: 'nemyesh megdarha
Cls 'neveshtan ebarat tol
Locate 1 , 1 'neveshtan ebarat tool
Lcd "tool:"
Locate 1 , 8
Lcd Tool1 'neveshtan megdar tool
Locate 2 , 1
Lcd "tedad:" 'neveshtan ebarat tedad
Locate 2 , 8
Lcd Tedad1 'neveshtan megdar tedad
C1 = 1 'vared shodan etelat
Goto Valuekeylcd
Counterlcd:
If C3 = 1 Then Goto Nex230
Set Cuter 'etminan az nabodan chizi zire cuter
Reset Motor
Waitms 120
'Reset Motor : C3 = 0
'Reset Cuter : C2 = 0
Set Portd.1 : C3 = 1
Reset Cuter
Enable Int0 'sensor
Config Int0 = Rising
Enable Interrupts
On Int0 Qqq
Goto Nex230
Nex230:
Do
If C3 = 1 Then
Set Portd.1 : C3 = 1
Reset Cuter
End If
A = Getkbd()
If A = 12 Then Goto Show7 'stop barname
Loop
Valuekeylcd:
Do
A = Getkbd()
If A < 16 Then Goto Show1 'nemayesh adad
Loop
Show1:
Select Case A
Case 3 : Goto Show2 'a=set
Case 1 : Goto Show3 'a=enter
Case 0 : Goto Show4 'a=f4
Case 4 : Goto Show5 'a=f3
Case 8 : Goto Show6 'a=f2
Case 12 : Goto Show7 'a=f1
End Select
If C1 = 1 Then Goto Valuekeylcd
B = Lookupstr(a , W)
B1 = B1 + B
Lcd B
Do
A = Getkbd()
Loop Until A = 16
Goto Valuekeylcd
Show2: 'a=set
If C1 = 1 Then Goto Valuekeylcd
If C = 0 Then 'etminan zadan set
Tool1 = Val(b1)
Tool2 = Tool1
Goto Tedad
Else
Goto Valuekeylcd
End If
Show3:
If C1 = 1 Then Goto Valuekeylcd 'a=enter
If C = 1 Then 'etminan zadan enter
Tedad1 = Val(b1)
Tedad2 = Tedad1
Goto Disp
Else
Goto Valuekeylcd
End If
Show4: 'a=f4
If C1 = 1 Then Goto Valuekeylcd
Locate 2 , 1
Lcd " "
Locate 2 , 1
B1 = ""
B = ""
Goto Valuekeylcd
Show5:
'a=f3
Cls
Reset Motor : C3 = 0
Reset Cuter
Goto Main 'shroe dobare barname
Show6:
If C1 = 0 Then Goto Valuekeylcd 'a=f2
C3 = 0
Goto Counterlcd 'start barname
Show7: 'a=f1 stop
If C1 = 0 Then Goto Valuekeylcd
Reset Motor : C3 = 0
Reset Cuter
C3 = 0
C1 = 1
Goto Valuekeylcd
Qqq:
If C2 = 1 Then Goto Nex230 'etminan az inke motor dar hale kare cutter nacharkhad
' A = Getkbd()
'If A = 12 Then Goto Show7
'Incr Met1
'If Met = Met1 Then
' Met1 = 0
Decr Tool2
Locate 1 , 8 : Lcd Tool2
If Tool2 = 0 Then
Tool2 = Tool1
Decr Tedad2
Locate 1 , 8 : Lcd Tool2
Locate 2 , 8 : Lcd Tedad2
Reset Motor
Reset Cuter
'A = Getkbd()
'If A = 12 Then Goto Show7 'stop barname
Waitms 200
'Reset Motor : C3 = 0
Set Cuter : C2 = 1 'cutter mikhad beravd
Waitms 120
'Reset Motor
Reset Cuter
C2 = 0 'cutter rafte
If Tedad2 = 0 Then
Cls
Lcd "******END******"
Reset Motor : C3 = 0
Reset Cuter
Waitms 500
Goto Main 'etmam barname va ejraye dobare an
End
Else
'Reset Motor : C3 = 0
'Reset Cuter
Set Motor : C3 = 1
Tool2 = Tool1
Locate 1 , 8 : Lcd Tool2
Reset Cuter
'Goto Refrash
End If
'Else
'Goto Refrash
'End If
Else
'Goto Refrash
Set Motor : C3 = 1
'Tool2 = Tool1
' Locate 1 , 8 : Lcd Tool2
Reset Cuter
End If
' Set Motor : C3 = 1
' Reset Cuter
Return
W:
Data "F4" , "Enter" , "0" , "Set" , "F3" , "9" , "8" , "7" , "F2" , "6" , "5" , "4" , "F1" , "3" , "2" , "1"