How To Make A Human Following Robot Using Arduino

These are the following steps:-

Step 1:

Put all components on PCB of main control board and assemble it.

Step 2:

First connect the wire of first left motor to U1 and V1, after that connect real left motor to U2 V2 , after that connect front right motor U3 to V3, after that connect real right motor U4 to V4, after that connect TP4056 Module and connect its negative out pin to ground, after that connect lithium iron battery and connect it’s positive pin to B+ pin and it’s negative pin to B- pin of TP4056 Module, after that connect a switch and connect it’s one pin to positive out pin of TP4056 Module and it’s other pin to 5V and VM of board, after that connect a ultra sonic sensor and connect it’s VCC pin to 5V of the board and it’s ground pin to ground, after that connect it’s echo pin to A0 pin of the board and it’s triggered pin to A1 pin of the board, after that connect another connect ultra sonic sensor and connect it’s VCC pin to 5V pin of the board and it’s ground pin to ground and it’s echo pin to A2 pin of the board and it’s triggered pin to A3 pin of the board.

Step 3:

Now upload the code to arduino and test the project.

#define en1 4 //enable pin of channel 1
#define en2 7 //enable pin of channel 2
#define en3 10 //enable pin of channel 3
#define en4 13 //enable pin of channel 4
#define in1 2 //input 1
#define in2 3 //input 2
#define in3 5 //input 3
#define in4 6 //input 4
#define in5 8 //input 5
#define in6 9 //input 6
#define in7 11 //input 7
#define in8 12 //input 8
#define echo1 14
#define trig1 15
#define echo2 16
#define trig2 17
long duration, inches,inches1;
int cmd;
void setup() {
  Serial.begin(9600);
  pinMode(echo1, INPUT);
  pinMode(echo2, INPUT);
  pinMode(trig1, OUTPUT);
  pinMode(trig2, OUTPUT);
  pinMode(en1, OUTPUT);
  pinMode(en2, OUTPUT);
  pinMode(en3, OUTPUT);
  pinMode(en4, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(in5, OUTPUT);
  pinMode(in6, OUTPUT);
  pinMode(in7, OUTPUT);
  pinMode(in8, OUTPUT);
  digitalWrite(en1, HIGH);
 digitalWrite(en2, HIGH);
   digitalWrite(en3, HIGH);
 digitalWrite(en4, HIGH);
  digitalWrite(in8, LOW);
}
void loop() {
   digitalWrite(trig1, LOW);
   delayMicroseconds(2);
   digitalWrite(trig1, HIGH);
   delayMicroseconds(10);
   digitalWrite(trig1, LOW);
   duration = pulseIn(echo1, HIGH);
   inches = microsecondsToInches(duration);

    digitalWrite(trig2, LOW);
   delayMicroseconds(2);
   digitalWrite(trig2, HIGH);
   delayMicroseconds(10);
   digitalWrite(trig2, LOW);
   duration = pulseIn(echo2, HIGH);
   inches1 = microsecondsToInches(duration);
   delay(200);
   if(inches<8|inches1<8)cmd=1;
     else if(inches>8&inches<16&inches1>8&inches<16)cmd=2;
   else  if(inches1<16&inches1<inches)cmd=3;
   else if(inches<16&inches<inches1)cmd=4;
 else cmd=0;

  Serial.print(inches);
   Serial.print(" in ");
  Serial.print(inches1);
   Serial.print(" in ");
  switch(cmd){
     case 0:
Serial.println("stop");
 digitalWrite(in1, LOW);
 digitalWrite(in2, LOW); 
 digitalWrite(in3, LOW); 
 digitalWrite(in4, LOW); 
 digitalWrite(in5, LOW); 
 digitalWrite(in6, LOW); 
 digitalWrite(in7, LOW); 
 digitalWrite(in8, LOW);  
 
  
    break;
    case 1:
Serial.println("back");
digitalWrite(in1, LOW); 
 digitalWrite(in2, HIGH); 
 digitalWrite(in3, LOW); 
  digitalWrite(in4, HIGH); 
  digitalWrite(in5, LOW); 
  digitalWrite(in6, HIGH); 
  digitalWrite(in7, LOW); 
  digitalWrite(in8, HIGH); 
    break;
     case 2:
Serial.println("forward");
  digitalWrite(in1, HIGH); 
  digitalWrite(in2, LOW); 
  digitalWrite(in3, HIGH); 
  digitalWrite(in4, LOW); 
  digitalWrite(in5, HIGH); 
  digitalWrite(in6, LOW); 
  digitalWrite(in7, HIGH); 
  digitalWrite(in8, LOW); 
    break;
     case 3:
Serial.println("right");
 digitalWrite(in1, LOW); 
   digitalWrite(in2, HIGH); 
   digitalWrite(in3, LOW); 
  digitalWrite(in4, HIGH); 
  digitalWrite(in5, HIGH);
  digitalWrite(in6, LOW);  
  digitalWrite(in7, HIGH); 
  digitalWrite(in8, LOW); 
    break; case 4:
Serial.println("left");
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);  
  digitalWrite(in3, HIGH); 
  digitalWrite(in4, LOW); 
  digitalWrite(in5, LOW); 
  digitalWrite(in6, HIGH); 
  digitalWrite(in7, LOW); 
  digitalWrite(in8, HIGH); 
    break;
    } 



}
long microsecondsToInches(long microseconds) {
   return microseconds / 74 / 2;
}
Components
PCB Components
Circuit Diagrams
ARD Robo Kit

ARD Robo Kit

519 KB 34 downloads
HFL Robo

HFL Robo

1 MB 17 downloads
Gerber Files
Icon

ARD Robo Kit CADCAM 71 KB 21 downloads

...
Arduino Code
Icon

Arduino Zip File 901 B 31 downloads

...
Icon

Arduino Text File 3 KB 36 downloads

...
Useful Tools

Leave a Comment