برنامه حرفه ای کامل ربات خط یاب با  7 سنسور که برای هنر اموزان هنرستان شهدا درست شده. شما میتوانید با تغییر داده ها در برنامه بیسکام عملکرد ربات خودتون رو کاهش یا افزایش بدهید .یعنی درجه هوشمندی ربات دست شماست .جا داره که از مهندس سید نعیم موسوی و کورش علیفرد این دو استاد ارجمند برای ساخت این برنامه و اجازه استفاده همگان از ان کمال تشکر و سپاس را به عمل اوریم.

Declare Sub Motor_left(byval Var As Byte)
Declare Sub Motor_right(byval Var As Byte)
Declare Sub Backup

$regfile = "m32def.dat"
$crystal = 1000000
'$sim
Config Lcdpin = Pin , Db4 = Pind.2 , Db5 = Pind.3 , Db6 = Pind.4 , Db7 = Pind.5 , Rs = Pind.0 , E = Pind.1
Config Lcd = 16 * 2
Locate 1 , 1
Lcd "direct by"
Locate 2 , 1
"Lcd "shohada
Dim Sa As Byte
Dim Sb As Byte
Dim Sc As Byte
Dim Sd As Byte
Dim E As Byte
Dim Sf As Byte
Dim Sg As Byte
Dim All As Byte
Dim Ml As Byte
Dim Mr As Byte
'-----------------------------
'M_L
Config Pinb.0 = Output
Config Pinb.1 = Output
'M_r
Config Pinb.2 = Output
Config Pinb.3 = Output
Print
'sensor
Config Pina.0 = Input
Config Pina.1 = Input
Config Pina.2 = Input
Config Pina.3 = Input
Config Pina.4 = Input
Config Pina.5 = Input
Config Pina.6 = Input
'---------------------

Main:
If Pina.0 = 1 Then Sa = 1 Else Sa = 0
If Pina.1 = 1 Then Sb = 1 Else Sb = 0
If Pina.2 = 1 Then Sc = 1 Else Sc = 0
If Pina.3 = 1 Then Sd = 1 Else Sd = 0
If Pina.4 = 1 Then E = 1 Else E = 0
If Pina.5 = 1 Then Sf = 1 Else Sf = 0
If Pina.6 = 1 Then Sg = 1 Else Sg = 0

All = Sa + Sb : All = All + Sc : All = All + Sd : All = All + Sf : All = All + Sg : All = All + E
  If All = 0 Then
  Locate 1 , 1
Cls
Lcd "no scens"
Call Backup
Goto Main
  End If
If All > 3 Then
Locate 1 , 1
Cls
Lcd "black"
Call Motor_left(3)
Call Motor_right(3)
Ml = 3
Mr = 3
End If

If Sa = 1 Then
Locate 1 , 1
Cls
Lcd "       A"
Call Motor_left(3)
Call Motor_right(1)
Ml = 3
Mr = 1
Goto Main
End If

If Sb = 1 Then
Locate 1 , 1
Cls
Lcd "        B"
Call Motor_left(3)
Call Motor_right(2)
Ml = 3
Mr = 2
Goto Main
End If

If Sc = 1 Then
Locate 1 , 1
Cls
Lcd "      C"
Call Motor_left(3)
Call Motor_right(2)
Ml = 3
Mr = 2
Goto Main
End If

If Sd = 1 Then
Locate 1 , 1
Cls
Lcd "         D"
Call Motor_left(3)
Call Motor_right(3)
Ml = 3
Mr = 3
Goto Main
End If

If E = 1 Then
Locate 1 , 1
Cls
Lcd "     E"
Call Motor_left(2)
Call Motor_right(3)
Ml = 2
Mr = 3
Goto Main
End If

If Sf = 1 Then
Locate 1 , 1
Cls
Lcd "           F"
Call Motor_left(2)
Call Motor_right(3)
Ml = 2
Mr = 3
Goto Main
End If

If Sg = 1 Then
Locate 1 , 1
Cls
Lcd "   G"
Call Motor_left(1)
Call Motor_right(3)
Ml = 1
Mr = 3
Goto Main
End If

 

Sub Motor_left(var As Byte)
  Select Case Var
          Case 1
          Portb.0 = 1                                       'motor left BACK
          Portb.1 = 0
          Locate 2 , 1
          Lcd "ML ba"
          Case 2
          Portb.0 = 0                                       'motor left free
          Portb.1 = 0
          Locate 2 , 1
          Lcd "ML fr"
          Case 3
          Portb.0 = 0                                       'motor left forward
          Portb.1 = 1
          Locate 2 , 1
          Lcd "ML for"
          End Select
        End Sub
'*********************************** motor_right * timer2 ************************************************
Sub Motor_right(var As Byte)
  Select Case Var
          Case 1
          Portb.2 = 1                                       'motor right BACK
          Portb.3 = 0
          Locate 2 , 1
          Lcd "        MR ba"
          Case 2
          Portb.2 = 0                                       'motor right free
          Portb.3 = 0
          Locate 2 , 1
          Lcd "        MR fr"
          Case 3
          Portb.2 = 0                                       'motor right forward
          Portb.3 = 1
          Locate 2 , 1
          Lcd "        MR for"
          End Select
  End Sub
'******************************** backup motor ***********************************************
Sub Backup
 Call Motor_left(ml)
 Call Motor_right(mr)
End Sub

نوشته شده در تاریخ یکشنبه 18 اسفند 1387    | توسط: Farzad Yosef-Lavi    |    |
نظرات()