Project showcase
Fabrizzio and Casey Arduino Car

Fabrizzio and Casey Arduino Car © CC BY

We designed a car that was able to sense objects and turn to avoid them.

  • 1,770 views
  • 0 comments
  • 2 respects

Components and supplies

Constantly rotating servo motors
×2
A000066 iso both
Arduino UNO & Genuino UNO
×1
Wheels
×2
12002 04
Breadboard (generic)
×1
11026 02
Jumper wires (generic)
The amount you will need will vary depending on your design
×50
51gzz5eu9pl. sx425
Ultrasonic Sensor - HC-SR04 (Generic)
×1
09590 01
LED (generic)
×1

Necessary tools and machines

09507 01
Soldering iron (generic)

About this project

This project is intended for our High School class to learn to code and build a robot that can do obstacle detection and avoidance whilst also being given the building materials by the teacher. It works by using ultrasonic sensors and motors to detect the objects, reverse and then turn 95 degrees. The robot is powered by 6 AA batteries.

This is the top view of the robot.

This is the front view of the vehicle

Code

Full car photoC/C++
It is the car we built and it works using ultrasonic sensors and motors
No preview (download only).
Robot CodeC/C++
This is the code for the robot
#define trigPin 12
#define echoPin 13

int n; 
int duration, distance;

int lightPin = 0;  //define a pin for Photo resistor
int threshold = 250;

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);
    Serial.begin(9600);  //Begin serial communcation
    pinMode(11, 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);

     if(analogRead(lightPin) > threshold ){    
        digitalWrite(11, HIGH);
        Serial.println("high");
            digitalWrite(11, HIGH); 
delay(500);                   
digitalWrite(11, LOW);    
delay(50);                    
}
         
    else{
        digitalWrite(11, LOW);
        Serial.println("low"); 
    }

    delay(100);
    ;
}
}  

Schematics

The Schematic
Screen shot 2017 11 15 at 10 jswymzum4a dy5uhbkpic

Comments

Team Fabrizzio and Casey's Robot Cars

Default
taznmagic
  • 1 project
  • 0 followers

Additional contributors

  • He helped me build the robot and come up with the design. by Fabrizzio Caro

Published on

November 28, 2017

Members who respect this project

Profile eooucbil68Profilepic
See similar projects
you might like

Similar projects you might like

Arduino Uno Autonomous Car

Project tutorial by hannahmcneelyy

  • 16,087 views
  • 2 comments
  • 27 respects

Bluetooth Mini Car

Project showcase by Hesham

  • 10,864 views
  • 4 comments
  • 35 respects

Biometric Car Entry - True Keyless Car

Project showcase by Rajeev Velikkal

  • 7,733 views
  • 9 comments
  • 43 respects

Voice Controlled Car

Project tutorial by Yug_Ajmera

  • 32,462 views
  • 1 comment
  • 26 respects

Arduino 4WD RC Car

Project tutorial by Andriy Baranov

  • 28,623 views
  • 7 comments
  • 68 respects
Add projectSign up / Login