Arduino Demo: Obstacle Detection System

Introduction

 
Obstacle detection is a term in IoT for the identification of any obstacles located in our movement direction. It is quickly identified and avoids object-related incidents. This principle is applied in a variety of construction machinery scenarios — think drones, forklifts, cranes, etc. This definition gives our devices a minimal degree of knowledge.
 
In this chapter, you will learn how to set up an obstacle detection system using Arduino UNO.
 

Obstacle Detection System

 
Prerequisites for developing this system
 
Hardware requirements
 
Hardwares  Nos 
Arduino UNO   1
Obstacle detection sensor  1
10k ohm potentiometer   1
LCD crystal display   1
220-ohm resistor   1
Breadboard  1
Connecting wires  -
 
Software requirements
  • Arduino IDE (For uploading code to Arduino Microcontroller)
In this experiment, we can do three stages of work for creating a digital room thermometer
 
1. Connect all hardware
2. Write & upload code to Arduino board
3. Test our developed system
 
Stage 1 [Connecting all hardware]
 
 
Step 1
 
First, we can connect the LCD crystal display with the Arduino UNO board using Jumper wires. I am using a breadboard to extend power terminals for making this system.
 
Refer to the below LCD crystal pin diagram for making an easy connection with Arduino.
 
 
Place a 10K ohm potentiometer near the LCD crystal display. It can adjust the contrast of the LCD screen and create a power connection from Arduino +5V and GND right and left end of the potentiometer. Make a connection from the center terminal of the potentiometer to VEE (contrast control) LCD crystal display. (Refer to the connection diagram)
 
Pin Configuration
 
         Arduino                               Breadboard                                  LCD Crystal Display
  • Pin 3 ---------------------------------------------------------------------------> Data pin 4
  • Pin 4 ---------------------------------------------------------------------------> Data pin 5
  • Pin 5 ---------------------------------------------------------------------------> Data pin 6
  • Pin 6 ----------------------------------------------------------------------------> Data pin 7
  • Pin 8 ----------------------------------------------------------------------------> Register select
  • Pin 7 ----------------------------------------------------------------------------> Enable
  • + 5V -----------------> Potentiometer Right Terminal-------------------->Potentiometer Centre terminal ----> VEE (Contrast Control) LCD crystal
  • +5V ---------------------------> 220-ohm Resistor ------------------------> LED +5V pin [LCD Crystal]
  • GND ----------------------------------------------------------------------------->Potentiometer Left terminal, Ground pin & LED - Ground pin [Connect to both pin]
Step 2
 
Next, connect obstacle detection sensor to Arduino board as per the below pin Configuration.
 
Pin Configuration
 
        Obstacle detection sensor                                           Arduino
  • Vcc ---------------------------------------------------------------------> +5V
  • Signal -------------------------------------------------------------------> Pin2
  • GND ---------------------------------------------------------------------> GND
 
Stage 2 [Write & upload code to Arduino]
 
In this step, write code for Arduino using the Arduino IDE.
  1. Download Arduino software using this link here.
  2. Install and open an Arduino IDE in your PC/Laptop
  3. Connect your Arduino board to your computer using a USB data cable
  4. Copy and paste the below code into the Arduino IDE
    1. #include "LiquidCrystal.h"    
    2. #define SEN_PIN 2         
    3. #define LCD_PIN_RS  8    
    4. #define LCD_PIN_E 7    
    5. #define LCD_PIN_DB4 3    
    6. #define LCD_PIN_DB5 4    
    7. #define LCD_PIN_DB6 5    
    8. #define LCD_PIN_DB7 6    
    9. LiquidCrystal lcd(LCD_PIN_RS,LCD_PIN_E,LCD_PIN_DB4,LCD_PIN_DB5,LCD_PIN_DB6,LCD_PIN_DB7);    
    10. void setup() {    
    11.   Serial.begin(9600);    
    12.   lcd.begin(16, 2);    
    13. lcd.print("C#corner");    
    14.  lcd.setCursor(0,1);    
    15.  lcd.print("Obstacle Detection");    
    16.  delay(2000);    
    17.  pinMode(SEN_PIN,INPUT);    
    18. }    
    19.     
    20. void loop() {    
    21.     if (digitalRead(SEN_PIN)== LOW) {    
    22.     lcd.clear();    
    23.     lcd.setCursor(0,0);     
    24.   lcd.print("Obstacle Detected");    
    25.   }    
    26.   else    
    27.   {    
    28.  lcd.clear();    
    29.   lcd.setCursor(0,0);     
    30.   lcd.print("No obstacle detected ");    
    31.   }    
    32.   delay(200);    
    33.   }    
Save and upload this code to the Arduino UNO board. After the code upload is completed, the device can start to detect an obstacle from your way.
 
Stage 3 [Test our developed system]
 
Our developed obstacle detection system can detect an obstacle successfully.
 
 
 
In this chapter, you learned how to create an Obstacle Detection System using Arduino UNO R3.
 
That’s all for this chapter. I hope you enjoyed reading!!
Author
Naveenkumar Paramasivam
289 5.8k 630.8k
Next » Internet of Things: Raspberry PI