Obstacle Avoiding Robot Car in the size of Arduino Uno


In this video we will build a mini "obstacle avoiding robot" car in the size of Arduino UNO. We will control this car with an ATtiny85 mini board. We will use one L293D IC to drive the motors, and one HC-SR04 ultrasonic distance sensor to measure the distance. Required Hardware: ATtiny85 Mini Board - https://goo.gl/JYMLQZ L293D IC Motor Driver - https://goo.gl/9j84ft HC-SR04 Ultrasonic Sensor - https://goo.gl/RaBMmR L293D IC Motor Driver - https://goo.gl/sWegWC Rubber Wheels -https://goo.gl/v9Dk6K Bearing Wheel - https://goo.gl/A3bGWV Mini Breadboard - https://goo.gl/uvEhR1 3 in 1 Jumper Wires - https://goo.gl/EGTafY 9V Battery - https://goo.gl/xaD6Tf 9V Battery Connector - https://goo.gl/fLjKL7 Other Tools (Optional): DANIU Soldering Tool Kit - https://goo.gl/2oZhtu 20W Hot Melt Glue Gun - https://goo.gl/tVwhE5 For using the ATtiny85 with the Arduino IDE, you can watch the following tutorials: https://youtu.be/vPRpT_7rQNo https://youtu.be/ETPhiqBqXEY
The NewPing library is required for the code to work properly. Install the NewPing library from the library manager.

Source Code:
#include <NewPing.h>

#define trigPin 3
#define echoPin 2
#define motor1Back 0
#define motor1Forward 1
#define motor2Forward 4
#define DISTANCE 25

NewPing sonar(trigPin, echoPin, DISTANCE);

void setup(){
  pinMode(motor1Back, OUTPUT);
  pinMode(motor1Forward, OUTPUT);
  pinMode(motor2Forward, OUTPUT);
}

void loop(){
  uint8_t distance = sonar.ping_cm();

  if(distance){
    digitalWrite(motor1Back, LOW);
    digitalWrite(motor1Forward, LOW);
    digitalWrite(motor2Forward, LOW);
    delay(100);
    digitalWrite(motor1Back, HIGH);
    digitalWrite(motor1Forward, LOW);
    digitalWrite(motor2Forward, HIGH);
  } else {
    digitalWrite(motor1Back, LOW);
    digitalWrite(motor1Forward, HIGH);
    digitalWrite(motor2Forward, HIGH);
  }
  delay(100);
}