Pada malam hari yang dingin ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah robot yang bisa memindahkan barang dari satu tempat ke tempat yang lain secara otomatis, seperti halnya robot pramusaji yang bisa menyajikan hidangan, robot ini juga sama seperti itu namun yang dihidangkan adalah barang yang ukurannya sesuai dengan gripper yang dipakai pada robot, gripper ini fungsinya untuk menjapit benda agar bisa dibawa kemanapun. untuk skema dan program seperti berikut ini.
a. Arduino Uno
b. Driver Motor L298
c. Motor DC + Gearbox
d. Gripper + Motor Servo
e. Program Arduino IDE
#include <Wire.h>
#include <Servo.h>
int mtrkanan1 = 4;
int mtrkanan2 = 5;
int mtrkiri1 = 6;
int mtrkiri2 = 7;
Servo myservo;
int kecmtr1 = 9;
int kecmtr2 = 10;
void setup(){
myservo.attach(11);
pinMode(mtrkanan1,OUTPUT);
pinMode(mtrkanan2,OUTPUT);
pinMode(mtrkiri1,OUTPUT);
pinMode(mtrkiri2,OUTPUT);
pinMode(kecmtr1,OUTPUT);
pinMode(kecmtr2,OUTPUT);
}
void loop(){
buka();
maju();
berhenti();
buka();
japit();
berhenti();
muter();
berhenti();
maju();
kiri();
berhenti();
maju();
berhenti();
buka();
berhenti();
mundurbentar();
japit();
mundur();
berhenti();
kiri();
berhenti();
}
void maju(){
analogWrite(kecmtr1,200);
digitalWrite(mtrkanan1,LOW);
digitalWrite(mtrkanan2,HIGH);
analogWrite(kecmtr2,200);
digitalWrite(mtrkiri1,HIGH);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
void mundur(){
analogWrite(kecmtr1,200);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,200);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,HIGH);
delay(2000);
return;
}
void buka(){
myservo.write(40);
delay(1000);
return;
}
void japit(){
myservo.write(100);
delay(1000);
return;
}
void berhenti(){
analogWrite(kecmtr1,0);
digitalWrite(mtrkanan1,LOW);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,0);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
void mundurbentar(){
analogWrite(kecmtr1,200);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,200);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,HIGH);
delay(500);
return;
}
void kiri(){
analogWrite(kecmtr1,120);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,0);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
void kanankanan(){
analogWrite(kecmtr1,0);
digitalWrite(mtrkanan1,LOW);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,120);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,HIGH);
delay(2000);
return;
}
void muter(){
analogWrite(kecmtr1,120);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,0);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
#include <Servo.h>
int mtrkanan1 = 4;
int mtrkanan2 = 5;
int mtrkiri1 = 6;
int mtrkiri2 = 7;
Servo myservo;
int kecmtr1 = 9;
int kecmtr2 = 10;
void setup(){
myservo.attach(11);
pinMode(mtrkanan1,OUTPUT);
pinMode(mtrkanan2,OUTPUT);
pinMode(mtrkiri1,OUTPUT);
pinMode(mtrkiri2,OUTPUT);
pinMode(kecmtr1,OUTPUT);
pinMode(kecmtr2,OUTPUT);
}
void loop(){
buka();
maju();
berhenti();
buka();
japit();
berhenti();
muter();
berhenti();
maju();
kiri();
berhenti();
maju();
berhenti();
buka();
berhenti();
mundurbentar();
japit();
mundur();
berhenti();
kiri();
berhenti();
}
void maju(){
analogWrite(kecmtr1,200);
digitalWrite(mtrkanan1,LOW);
digitalWrite(mtrkanan2,HIGH);
analogWrite(kecmtr2,200);
digitalWrite(mtrkiri1,HIGH);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
void mundur(){
analogWrite(kecmtr1,200);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,200);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,HIGH);
delay(2000);
return;
}
void buka(){
myservo.write(40);
delay(1000);
return;
}
void japit(){
myservo.write(100);
delay(1000);
return;
}
void berhenti(){
analogWrite(kecmtr1,0);
digitalWrite(mtrkanan1,LOW);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,0);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
void mundurbentar(){
analogWrite(kecmtr1,200);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,200);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,HIGH);
delay(500);
return;
}
void kiri(){
analogWrite(kecmtr1,120);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,0);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
void kanankanan(){
analogWrite(kecmtr1,0);
digitalWrite(mtrkanan1,LOW);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,120);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,HIGH);
delay(2000);
return;
}
void muter(){
analogWrite(kecmtr1,120);
digitalWrite(mtrkanan1,HIGH);
digitalWrite(mtrkanan2,LOW);
analogWrite(kecmtr2,0);
digitalWrite(mtrkiri1,LOW);
digitalWrite(mtrkiri2,LOW);
delay(2000);
return;
}
f. VIDEO HASILNYA
No comments:
Post a Comment