Skip to main content

Arduino Smart Car

Smart Car


        In this Arduino Tutorial I will show You How to make a Smart Car using Arduino Uno Board and other some Electronic Components. You can Watch this Video or Read the Following Blog for more details.


Working Principle :

    This Smart Car has a Basic and necessary component UltraSonic and IR sensors. Both the Sensors are Used to Detect Obstacles to avoid from it. Then the Both Sensors mounted on the Car that Detects and Avoids Car from Collision.

Required Components :

Construction :

  • First you need a cardboard of high Durability.
  • And Mount a Gear motors Using Double Sided Tape or GlueGun.
  • Place the Arduino Uno Board on the Cardboard Connected With L293D Motor Driver.
  • Connect the Gear motor Wires to the L293D Motor Driver.
  • And place the UltraSonic Sensor infront of the Cardboard.
  • Attach IR Sensors on the sides of Car to detect Objects.
  • Connect Sensors to the Motor Driver Using Jumper Wires.
  • Make sure your Sensors Output Pins are Correctly Mounted with the Analog input Pins of Motor Driver.
  • Now move on to the Software Portion, Open Your Arduino IDE
  • Select smart_car.ino file 
  • Download Required Libraries and Select Board & Port , Click Upload .
  • Now time to Connect a Battery. I use 2no's of li-ion 3.7V battery in Series Connection.
  • After Connecting Batteries, Switch on your Car and Place it on Track, That will Avoids the Obstacles in its track and perfectly run on its track .
  • That's Solve Guys !

Circuit Diagram :

        You can follow our DIY Video for Circuit Diagram. I will clearly explained the connections of this Smart Car.

Arduino Code :

//CRATUS MK7
//SMART CAR
//BY PRADEEP RAJ(M.P.R)
//MAY 15 2020
//          ------THIS CODE IS OPEN SOURCE FOR OUR SUBSCRIBERS------
//                         ------ THE FAUCETER ------

#include<AFMotor.h>
#include<NewPing.h>

#define left A1
#define right A0
#define trig A2
#define echo A3
#define MAX_DISTANCE 100

NewPing sonar(trig,echo,MAX_DISTANCE);

AF_DCMotor motor1(1,MOTOR12_1KHZ);
AF_DCMotor motor2(2,MOTOR12_1KHZ);
AF_DCMotor motor3(3,MOTOR34_1KHZ);
AF_DCMotor motor4(4,MOTOR34_1KHZ);

void setup() {
  // put your setup code here, to run once:
  pinMode(left,INPUT);
  pinMode(right,INPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int distance = sonar.ping_cm();

  Serial.print("Distaance");
  Serial.println(distance);

  if (distance >13) {
    motor1.setSpeed(200);
    motor1.run(FORWARD);
    motor2.setSpeed(200);
    motor2.run(FORWARD);
    motor3.setSpeed(200);
    motor3.run(FORWARD);
    motor4.setSpeed(200);
    motor4.run(FORWARD);
  }
  else if (distance <=14 && distance >0) {
    Stop();
    delay(100);
    if (digitalRead(right)==0 && digitalRead(left)==0) {
      turnright();
      delay(400);
    }

    else if (!digitalRead(right)==0 && digitalRead(left)==0) {
      turnleft();
      delay(400);
    }

    else if (digitalRead(right)==0 && !digitalRead(left)==0)  {
      turnright();
      delay(400);
    }

    else if (!digitalRead(right)==0 && !digitalRead(left)==0)  {
      turnaround();
      delay(1600);
    }
  }
   else if (!digitalRead(right)==0 && digitalRead(left)==0) {
     turnleft();
     delay(100);
    }

   else if (digitalRead(right)==0 && !digitalRead(left)==0)  {
     turnright();
     delay(100);
    }
}

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);
}

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

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

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





//-----------------------------------------------------THE FAUCETER----------------------------------------------------------------------------------------

Click Here to Download

Comments

Popular posts from this blog

Arduino Line Following Car

Line Follower      In this Arduino Tutorial I will Show you How to Make a Line Following Car Using Arduino Uno Board and Some Electronic Components . You can Watch this Video or Read the following blog for more details.. Working Principle :          Line Follower has a basic and necessary Component   IR Sensor which act as Vision. It works on the principle of Black Surface Absorbs all  Wavelengths of Light Rays. Then the IR Sensors mounted infront of the car detects black line and makes a movement based on your code.

Measuring Distance Using UltraSonic Sensor with Arduino

Measuring Distance     Using Arduino, UltraSonic Sensor & OLED Display                In this Arduino Tutorial , I will show you How to Measure a Distance of an Object Using Arduino , UltraSonic Sensor & OLED Display . You can watch this Video or Read the following Blogs for More Details.

NodeMCU WiFi Car

 WiFi Car    In this Tutorial I will Show you How to Make a WiFi Car Using NodeMCU ESP8266 Board and Some Electronic Components . You can Watch this Video or Read the following blog for more details..

N95 Respirator Mask

N95

Arduino Object Following Robot

Object Following Robot     Watch the entire DIY Video of making (J.A.O.F) Arduino Object Following Robot...

NodeMCU WiFi Switch

 Wi-Fi Switch          In this Tutorial , I will Show you How to Control your Home Appliances by Using Smartphone Over WiFi Connection with NodeMCU ESP8266 Board and Relay(Electric Switch). You can watch this Video or read the following Blog for more Details...