Project tutorial
Arduino Uno Autonomous Car

Arduino Uno Autonomous Car

A car that avoids objects while led lights are activated.

  • 12,259 views
  • 0 comments
  • 26 respects

Components and supplies

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)

About this project

I am currently in a robotics class learning how to program and make different kinds of robots that do different actions. I made a Arduino car that can sense things in front of it avoiding the obstacle while LED lights are flashing. It works by using ultrasonic sensors to avoid objects by using servo motors.

<iframe width="560" height="315" src="https://www.youtube.com/embed/J7k_hHim8Y0" frameborder="0" allowfullscreen></iframe>

<iframe width="560" height="315" src="https://www.youtube.com/embed/J7k_hHim8Y0" frameborder="0" allowfullscreen></iframe> 

Code

Arduino CodeArduino
Use it to program car
#define trigPin 12
#define echoPin 13

int n; 
int duration, distance;

String readString;

#include <Servo.h> 
Servo myservo1;  // create servo object to control servo 
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(8); // assigns the servo to a pin
  myservo2.attach(9);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(3, OUTPUT);
}

void loop() {
  digitalWrite(trigPin, HIGH);
  _delay_ms(500);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
        
  if (distance < 40) { // this is the distance which the rover has to stop
    digitalWrite(3, HIGH);
    myservo1.write(n); // controls the direction of the motors
    myservo2.write(180-n);
   delay(1000);  // how long the wheels spin
   myservo1.write(n);
   myservo2.write(90-n);
   delay(500);
}
  else { // what the rover will do if it doen't sense anything
    digitalWrite(3, LOW);
    myservo1.write(180-n);
    myservo2.write(n);
}
}  

Schematics

Diagram
Shows how to wire the bread board
Screen shot 2017 11 15 at 10 jswymzum4a

Comments

Author

Default
hannahmcneelyy
  • 1 project
  • 2 followers

Additional contributors

  • Originally making robot by Nicky Godoff

Published on

November 15, 2017

Members who respect this project

Default1f8ab6d2 a730 46b5 b93b bc8d3149f3f8 ysonhhpdwoProfile eooucbil686e549836 e4b3 414f b0f7 a7be4cba9f68 xrwrkpxxpwDefaultOpenbuildslogo bluebox86d418fa 54f8 46fe a940 89f73db9af27 y9f5nuqc9oDefault

and 18 others

See similar projects
you might like

Similar projects you might like

Fabrizzio and Casey Arduino Car

Project showcase by Team Fabrizzio and Casey's Robot Cars

  • 1,159 views
  • 0 comments
  • 2 respects

Android Arduino RC Car

Project tutorial by RAFI RASHEED T C

  • 15,340 views
  • 2 comments
  • 38 respects

Arduino 4WD RC Car

Project tutorial by Andriy Baranov

  • 13,133 views
  • 3 comments
  • 43 respects

Probability | Autonomous Rover

Project in progress by colepurtzer

  • 6,235 views
  • 19 comments
  • 41 respects

Tito - Arduino UNO 3D-printed robot

Project tutorial by Camilo Parra Palacio

  • 10,729 views
  • 10 comments
  • 39 respects
Add projectSign up / Login