Kontrol
Robot ARM Mengunakan Arduino
Dan
Interface VB .NET
Robot Arm adalah sejenis robot yang berfungsi seperti lengan
kita, lengan manusia. Ada siku (elbow), pergelangan
(wrist), ada pula bagian untuk memegang/menjepit (grip). Penampakannya terlihat pada gambar :
Gb.1. Robot Arm
Terdapat lima servo : Base, Shoulder, Elbow, Wrist dan Grip. Jadi kita perlu lima pin Arduino yang dihubungkan ke masing masing servo.
Gb.2. Rangkaian Motor DC
Pada latihan kali ini kita
akan memprogram pengendali robot arm sederhana. Cukup mengontrol posisi masing –
masing servo secara manual. Untuk pembelajaran yang lebih advanced anda dapat
mempelajarinya dengan teori
penunjang Invers Kinematik.
Gb.3. Robot Arm, Relay +VB.NET
Program Arduino :
const int ledPin1 = 2; // the number of the LED pin
const int ledPin2 = 3;
const int ledPin3 = 4;
const int ledPin4 = 5;
const int ledPin5 = 6;
const int ledPin6 = 7;
const int ledPin7 = 8;
const int ledPin8 = 9;
String datamasukan;
int bitlampu;
int lampu1;
int lampu2;
int lampu3;
int lampu4;
int lampu5;
int lampu6;
int lampu7;
int lampu8;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin8, OUTPUT);
//Serial.println("Masukkan data: ");
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
delay(500);
}
void loop() {
if (Serial.available() > 0) {
datamasukan = Serial.readStringUntil('\n');
bitlampu = datamasukan.toInt();
lampu1=bitlampu & 1;
lampu2=bitlampu & 2;
lampu3=bitlampu & 4;
lampu4=bitlampu & 8;
lampu5=bitlampu & 16;
lampu6=bitlampu & 32;
lampu7=bitlampu & 64;
lampu8=bitlampu & 128;
if(lampu1==1){
digitalWrite(ledPin1,HIGH);
}
else{digitalWrite(ledPin1,LOW);}
if(lampu2==2){
digitalWrite(ledPin2,HIGH);
}
else{digitalWrite(ledPin2,LOW);}
if(lampu3==4){
digitalWrite(ledPin3,HIGH);
}
else{digitalWrite(ledPin3,LOW);}
if(lampu4==8){
digitalWrite(ledPin4,HIGH);
}
else{digitalWrite(ledPin4,LOW);}
if(lampu5==16){
digitalWrite(ledPin5,HIGH);
}
else{digitalWrite(ledPin5,LOW);}
if(lampu6==32){
digitalWrite(ledPin6,HIGH);
}
else{digitalWrite(ledPin6,LOW);}
if(lampu7==64){
digitalWrite(ledPin7,HIGH);
}
else{digitalWrite(ledPin7,LOW);}
if(lampu8==128){
digitalWrite(ledPin8,HIGH);
}
else{digitalWrite(ledPin8,LOW);}
}
}
Program VB.NET :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.PortName = "COM17"
SerialPort1.BaudRate = 9600
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.DataBits = 8
SerialPort1.Open()
If SerialPort1.IsOpen = False Then
MsgBox("Cek Koneksi", vbCritical)
Else
Button1.Enabled = False
Button2.Enabled = True
Button3.Enabled = True
Timer1.Enabled = True
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "L1 ON" Then
Button2.Text = "L1 OFF"
Else
Button2.Text = "L1 ON"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "L2 ON" Then
Button4.Text = "L2 OFF"
Else
Button4.Text = "L2 ON"
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If Button5.Text = "L3 ON" Then
Button5.Text = "L3 OFF"
Else
Button5.Text = "L3 ON"
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If Button6.Text = "L4 ON" Then
Button6.Text = "L4 OFF"
Else
Button6.Text = "L4 ON"
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If Button7.Text = "L5 ON" Then
Button7.Text = "L5 OFF"
Else
Button7.Text = "L5 ON"
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If Button8.Text = "L6 ON" Then
Button8.Text = "L6 OFF"
Else
Button8.Text = "L6 ON"
End If
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If Button9.Text = "L7 ON" Then
Button9.Text = "L7 OFF"
Else
Button9.Text = "L7 ON"
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
If Button10.Text = "L8 ON" Then
Button10.Text = "L8 OFF"
Else
Button10.Text = "L8 ON"
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim angkakirim As Integer = 0
If Button2.Text = "L1 OFF" Then
angkakirim = angkakirim + 1
End If
If Button4.Text = "L2 OFF" Then
angkakirim = angkakirim + 2
End If
If Button5.Text = "L3 OFF" Then
angkakirim = angkakirim + 4
End If
If Button6.Text = "L4 OFF" Then
angkakirim = angkakirim + 8
End If
If Button7.Text = "L5 OFF" Then
angkakirim = angkakirim + 16
End If
If Button8.Text = "L6 OFF" Then
angkakirim = angkakirim + 32
End If
If Button9.Text = "L7 OFF" Then
angkakirim = angkakirim + 64
End If
If Button10.Text = "L8 OFF" Then
angkakirim = angkakirim + 128
End If
TextBox1.Text = angkakirim
SerialPort1.WriteLine(TextBox1.Text + Chr(13))
End Sub
End Class
LINK VIDEO KAMI : https://www.youtube.com/watch?v=s6vN1pPN6GQ&feature=youtu.be