My First Robot using Arduino platform
Yo, Whasup People.
My Name is Frost, Im from Indonesia, Im 13 years old.
Today, im going to show you my first robot that ive made a few days ago, that is obstacle avoider.
This robot works simply. When it detected object in front of him, it will stopped automotically. Here is the photo that i taken last night with my phone:
And here is the whole script/program code that make my robot able to work if you guys are interested to check the program code:
#include <NewPing.h>
#define Trig 9
#define Echo 10
#define jarakMax 200
const int E1=5;
const int M1=4;
const int E2=6;
const int M2=7;
// Warna orange biru kanan M2
// warna merah putih kiri
NewPing sensor(Trig,Echo, jarakMax);
void setup(){
pinMode(E1, OUTPUT);
pinMode(M1, OUTPUT);
pinMode(E2, OUTPUT);
pinMode(M2, OUTPUT);
}
void loop(){
int jarak=sensor.ping_cm();
Serial.begin(115200);
Serial.print(jarak);
Serial.println(" Cm");
int batas=10;
if(jarak>0 && jarak<batas){
rem();
}
else{
maju();
}
}
void rem(){
digitalWrite(E1, LOW);
digitalWrite(E2, LOW);
digitalWrite(M1, LOW);
digitalWrite(M2, LOW);
}
void kananMaju(){
digitalWrite(M2, HIGH);
digitalWrite(E2, HIGH);
}
void kiriMaju(){
digitalWrite(M1, HIGH);
digitalWrite(E1, HIGH);
}
void maju(){
kananMaju();
kiriMaju();
}
NB:You guys might dont understand All name of My custom function, because, i made these functions names based on Indonesian Language.