Obstacle Avoider Using Ultrasonic Sensor

(0 review)
Free
Check out

In this project you will be introduced to ultrasonic sensor and how to use it. And we’re going to build obstacle avoider robot using ultrasonic sensor which avoids obstacles or drives itself not running into a obstacle and finds itself a safer path.

us

This project helps in measuring the distance between the robot and the object (obstacle) by calculating the time between transmitted wave and the receiving wave.

us-range

KIT: Junkbot Edu kit.

Hardwire required:

  • Arduino Uno
  • Breadboard
  • Ultrasonic sensor
  • Motor driver IC
  • DC motors
  • USB cable
  • Connecting wires

Code brick program:

52

Fritzing image:

53

How to test ultrasonic sensor:

  1. How to connect the ultrasonic sensor to Arduino.

We can test the ultrasonic sensor as the distance measurement the procedure is illustrated below.

  • Connect TRIG and ECHO pin of ultrasonic sensor to 12 and 13 pins of Arduino.

54

  • Connect the Vcc pin of the sensor to 5v of Arduino.
  • Connect the GND pin of the sensor to GND of Arduino.

      2.How to write to code to measure the distance and display using code bricks and upload it to                  Arduino.

  • Open the code bricks and drag55 .
  • To show the distance using your sprite use56 from looks.
  • Now to read ultrasonic sensor drag 57 from robots.
  • Use the 39 loop for continuous display of the distance.
  • So when you click40 on the59 will be showing the distance between your ultrasonic sensor and obstacle.

60

  • Connect the USB cable to arduino and laptop.
  • Go to BOARDS and select arduino uno.17
  • Go to CONNECT and select the usb port and wait until it says serial port connected.22

 

  •  The dot will turn from red to green, representing the connection established.16

 

  • Once port is connected upgrade the firmware and wait until it upload is finish.19                                           20

 

 

 

      3.Obstacle avoider configuration:

The configuration of obstacle avoider using the ultrasonic sensor is stated below.

  • Connect TRIG and ECHO pin of ultrasonic sensor to 12 and 13 pins of Arduino.
  • Connect 8,9,10 and 11 pins of Arduino to A-1A, A-1B, B-1A and B-1B and also connect Vcc and GND of Arduino to VIN and GND of motor driver IC.
  • Set pins 8 and 10 of Arduino to HIGH and connect the positive (red wire) of right motor and left motor respectively.
  • Set pins 9 and 11 of Arduino to LOW and connect the negative (black wire) of right motor and left motor respectively.

      4.How to write the code for obstacle avoider using the code bricks and upload to Arduino.

  • Open the code bricks software.
  • Click on the robots and drag61 .
  • To read the values of ultrasonic sensor use 57 brick from the robots.
  • So to stop or turn your obstacle avoider robot at certain distance before obstacle or a wall you can set limit using the Screenshot (113) brick from operators.
  • This brick actually helps to set different kind of distance like 5cm ,10cm,15cm say if you want your robot to stop or turn less than 10cm before the obstacle use the brick as illustrated 63.
  • So if the distance between your robot and the obstacle is less than 10cm then robot stops or turn else it will move in forward direction to follow this statement we use Screenshot (115)brick from control.
  • Now to make your robot moving the forward direction connect all the the blocks above as shown .Screenshot (116)

 

  • Now to make your robot to stop useScreenshot (117)  and to turn useScreenshot (153)  the bricks respectively.

 

  • To upload into Arduino use and to make your robot continuously move use 39 brick.
  •  So following up all the above steps we created a code that makes your robot move stop or turn if the distance is less than 10cm else it will move forward the code is illustrated below.

      5.Uploading to Arduino:

In this case the code we built should be uploaded into Arduino as illustrated below.

  • And to upload this code into Arduino right click on the Arduino program and click on upload to Arduino.68 .
  • After clicking on upload to Arduino should find one more window opening where we find upload to Arduino click on it you find the uploading progress.69
  • Once the upload is finished disconnect the USB and connect power bank to Arduino Uno the robot will start moving as per the code given.

 

This project is more like a autonomous after uploading the code into Arduino and give power supply via connected to computer or power bank it starts working. Its recommended to use the power bank once the code is uploaded in to Arduino.

The obstacle avoider robot moves according to the assigned instructions autonomously.

Course Features

  • Lectures 0
  • Quizzes 0
  • Duration 50 hours
  • Skill level All level
  • Language English
  • Students 16
  • Certificate No
  • Assessments Self
  • autonomous robot

Reviews

Average Rating

0
0 rating

Detailed Rating

5 stars
0
4 stars
0
3 stars
0
2 stars
0
1 stars
0
Free