iklan banner

Membuat Kendali Robot Menggunakan Bluetooth dan Computer ( Komputer PC )

Membuat Kendali Robot Menggunakan Bluetooth dan Computer ( Komputer PC )


            Kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah robot yang canggih yaitu robot yang bisa dikendalikan maju, mundur, kiri dan kanan menggunakan komputer, komunikasi yang digunakan adalah bluetooth, jadi untuk masalah jarak tidak bisa terlalu jauh tergantung spesifikasi yang dipakai baik itu bluetooth komputer maupun HC-05 yang dipakai oleh robot, robot ini menggunakan program interface VB 6. untuk lebih jelasnya berikut penjelasanya.



a. Minimum System + L293





b. Bluetooth HC-05





c. Program Bascom AVR

$regfile = "m8def.dat"
$crystal = 12000000
$baud = 9600

Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up

Enable Interrupts

Dim Perintah As String * 1

Ddrb.0 = 1
Ddrd.7 = 1
Ddrd.6 = 1
Ddrd.5 = 1

Dirkiri1 Alias Portb.0
Dirkiri2 Alias Portd.7
Dirkanan1 Alias Portd.6
Dirkanan2 Alias Portd.5


Do
Perintah = Waitkey()

Select Case Perintah

Case "1" :
  'maju
   Dirkiri1 = 1                                             'motor kiri
   Dirkiri2 = 0
   Dirkanan1 = 0                                            'motor kanan
   Dirkanan2 = 1
   Pwm1a = 200
   Pwm1b = 200

Case "2" :
  'mundur
   Dirkiri1 = 0                                             'motor kiri
   Dirkiri2 = 1
   Dirkanan1 = 1                                            'motor kanan
   Dirkanan2 = 0
   Pwm1a = 200
   Pwm1b = 200

Case "3" :
  'kanan
   Dirkiri1 = 1                                             'motor kiri
   Dirkiri2 = 0
   Dirkanan1 = 1                                            'motor kanan
   Dirkanan2 = 1
   Pwm1a = 200
   Pwm1b = 200

Case "4" :
  'kiri
   Dirkiri1 = 1                                             'motor kiri
   Dirkiri2 = 1
   Dirkanan1 = 0                                            'motor kanan
   Dirkanan2 = 1
   Pwm1a = 200
   Pwm1b = 200

Case "7" :
  'kiri
   Dirkiri1 = 0                                             'motor kiri
   Dirkiri2 = 0
   Dirkanan1 = 0                                            'motor kanan
   Dirkanan2 = 0
   Pwm1a = 0
   Pwm1b = 0

End Select
Loop




d. Program Interface VB 6



Dim arrdata()
Dim TotalBaca As Integer
Dim BMI As Single
Dim Keterangan As String
Const MAKSBACA = 10
'-----------------------------
Private Sub atas_Click()
MSComm2.Output = "1" + Chr(13)  'mengirimkan angka 1 ke serial
End Sub
'-----------------------------
Private Sub bawah_Click()
MSComm2.Output = "2" + Chr(13)  'mengirimkan angka 2 ke serial
End Sub
'-----------------------------
Private Sub berhenti_Click()
  start.Enabled = True
    berhenti.Enabled = False
    TimerBaca.Enabled = False
End Sub
'-----------------------------

Private Sub BUZZ_Click()
MSComm2.Output = "5" + Chr(13)
End Sub

Private Sub Command1_Click()
MSComm2.Output = "7" + Chr(13)
End Sub

'-----------------------------
Private Sub Command2_Click()
Unload Me
End Sub


Private Sub Down_Click()

End Sub

'-----------------------------
Private Sub Form_Load()
Dim i As Byte
For i = 1 To 16
    ComboCOM.AddItem (i)
Next i
End Sub

Private Sub kanan_Click()
MSComm2.Output = "4" + Chr(13)
End Sub

Private Sub kiri_Click()
MSComm2.Output = "3" + Chr(13)
End Sub

'----------------------------
Private Sub start_Click()
Dim u As Integer
    On Error GoTo ada_eror
    MSComm2.CommPort = ComboCOM.Text
    MSComm2.Settings = "9600,N,8,1"
    MSComm2.RThreshold = 15
    MSComm2.InputLen = 15
    MSComm2.InputMode = comInputModeText
    MSComm2.PortOpen = True
    ReDim arrdata(1 To MAKSBACA + 1)
    For u = 1 To MAKSBACA
        arrdata(u) = 0
    Next
    TotalBaca = 0
    start.Enabled = False
    berhenti.Enabled = True
    TimerBaca.Enabled = True
ada_eror:
 If ComboCOM.ListIndex < 1 Then
    MsgBox "COM berada di Nomor : " & Err.Number & vbCrLf & Err.Description, vbCritical + vbOKOnly, "ERROR"
    start.Enabled = True
    berhenti.Enabled = True
    ComboCOM.Text = "Pilih COM"
End If
End Sub
'-----------------------------------
Private Sub TimerBaca_Timer()
Dim strInput As String
Dim strPotong As String
Dim singleInput As Single
Dim u As Integer
'    strInput = MSComm2.Input
    '    strPotong = strInput
        'Text1.Text = Text1.Text + strPotong + vbCrLf
     '   singleInput = Val(strPotong)
      '  If TotalBaca >= MAKSBACA Then
       '     TimerBaca.Enabled = False
       '     If MSComm2.PortOpen = True Then MSComm2.PortOpen = False
       '     Call berhenti_Click
       ' End If
End Sub




e. VIDEO HASILNYA