Table of Contents

Voice Controlled Robo-Car with Obstacle Avoidance

1221B Yunis Saleh

Introducere

The scope of this project is to create a Robo-Car that is controlled by voice commands or via a Dpad using third party applications, the Robo-Car will also have an obstacle avoidance function assisted by 2 IR sensors and an ultrasonic distance sensor.

Descriere generală

We'll stack a Motor Shield on our Arduino Uno and connect it to 4 dc motors, it'll also be connected with a bluetooth module that will be used to control the car with a Dpad or voice commands using third party applications, We'll also connect 2 IR sensors & an Ultrasonic distance sensor rotated by a Servo motor for obstacle avoidance.

Hardware Design

List of components:

Electrical Scheme:

Software Design

I used Arduino IDE to write and upload the code.

Libraries:

3rd party apps:

Functions implemented:

All of these functions are quite similar in logic, one method for each direction in the Dpad control

Here is the forward direction method:

void fdpad()
 {
   motor1.setSpeed(200); 
   motor1.run(BACKWARD); 
   motor2.setSpeed(200);
   motor2.run(FORWARD);
   motor3.setSpeed(200); 
   motor3.run(FORWARD); 
   motor4.setSpeed(200); 
   motor4.run(BACKWARD); 
 } 

This is the first function for the voice control and obstacle avoidance, it calculates the distance using the HC-SR04 sensor, the method calls the fdpad() method unless the distance is less than 10cm, then it'll call the stop() method:

 void forward() 
 {
  int distance = sonar.ping_cm();

  if(distance < 10){
   Stop();
   voice="";
  }
  else {
   fdpad();
   }
 }

These are of similar logic to forward() only that after calling the topr() or topl() method there will be a delay of 0.5s till the motors stop (motor1.run(RELEASE);), used for voice control.

This method calls the bdpad() method unless one of our IR sensors senses an object, then we call the stop() method:

 void backward() 
 {
  int IR_Sensor1 = digitalRead(IR1);
  int IR_Sensor2 = digitalRead(IR2);

  if(IR_Sensor1 == 0 || IR_Sensor2 == 0)
  {
    Stop();
    voice="";
  }
  else {
    bdpad();
  }
 }

Call the bottomr() or bottoml method, stops the motors after 0.5s (motor1.run(RELEASE);).

Having our ultrasonic sensor mounted on a servo motor, these functions move the servo motor either to the right or left, then it goes back to the middle adding animation, then either the rdpad() or ldpad() method will be called, and the motors will stop after 0.7s:

 void left()
  {
    myservo.write(180);
    delay(500);
    myservo.write(90);
    delay(500);
    ldpad();
    delay(700);
    motor1.run(RELEASE);
    motor2.run(RELEASE);
    motor3.run(RELEASE);
    motor4.run(RELEASE);
  }
 void right() 
  {
    myservo.write(0);
    delay(500);
    myservo.write(90);
    delay(500);
    rdpad();
    delay(700);
    motor1.run(RELEASE);
    motor2.run(RELEASE);
    motor3.run(RELEASE);
    motor4.run(RELEASE);
  }

Stops the motors:

 void Stop()
  {
    motor1.setSpeed(0); 
    motor1.run(RELEASE); 
    motor2.setSpeed(0); 
    motor2.run(RELEASE); 
    motor3.setSpeed(0); 
    motor3.run(RELEASE); 
    motor4.setSpeed(0); 
    motor4.run(RELEASE); 
  }
  

Mostly if statements, when our input matches with 'F' or 'B' or 'L' or 'R' or…. then the corresponding dpad direction function will be called, when it matches “turn left” or “left” or “turn right” or “right or “top right” or….. then the corresponding voice functions will be called. when the input is “move forward” or “move backward”, the forward() or backward() methods will keep running in a while loop until one of the sensors senses a nearby object.

The full code is provided in the Download section

Rezultate Obţinute

Demo: https://youtube.com/watch?v=kqReeGgIopE

Concluzii

I had a lot of fun working on this project. being my first project with microcontrollers, I wanted to make a project that excites me, not the most useful and thought out project, nor the most special and unique. I wanted to make something fun, a toy that when I finish it would motivate me to work on more projects and ideas on my own time, and it certainly did.

Download

Code:

https://github.com/yunissalih/arduino-robo-car-with-voice-control/blob/2f5cbb1cdfad525cf146138914c6f9cd072ee7a4/obstacle_avoidance_voice_control_robot.ino

Demo:

https://www.youtube.com/watch?v=kqReeGgIopE

Schemes:

https://drive.google.com/drive/folders/1ri3wvXwRsiTgCdg-3eRLwvwvdVqLghQk?usp=sharing

BT Car (android):

https://drive.google.com/file/d/1DXr-QmpZ3TaMstY1qKcxu4LLNM26HiUW/view

Arduino Bluetooth controller (android):

https://drive.google.com/file/d/1xkiM3GqHRDYxyqz5ztFWlB-ux6jLU944/view

Jurnal

Bibliografie/Resurse

Export to PDF