Aug 25, 2016

Distance Measuring LED's Bar Graph For Parking Sensor

Distance Measuring LED's Bar Graph For Parking Sensor

Distance Measuring LED's Bar Graph For Parking Sensor

Hi!Today i going to show you that how to make a distance measuring LED bar graph with Alarm.Working and aim of this project is very clear that the Ultrasonic sensor will measure the distance and the LED bar graph will show you the output and also we are using a Buzzer that will warn you with different types of tones.Everything will happen with the help of an Arduino Board.This Project mostly used as a parking Sensor but you can use it at your door and as a Anti-theft Alarm.
Final Result:-Video Link:-

Requirements to Make A Parking Sensor :-

Distance Measuring LED's Bar Graph For Parking Sensor

1 x Arduino Board
1 x Breadboard
1 x Ultrasonic Sensor (HC-SR04)
1 x Buzzer (Pizzo buzzer)
1 x 74HC595 8 Bit Shift Register
8 x LEDs (3 x Red leds, 3 x Yellow leds, 2 x Green leds)
10 x 150ohm or 220ohm Register
Jumper wires

Basic Information About Parts and links to Buy -

Arduino UNO board

The Arduino Uno is a micro controller board based on the ATmega328. It contains everything needed to support the micro controller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs ,a 16 MHz ceramic resonator ,a USB connection ,a power jack ,an ICSP header and a reset button.

It contains everything needed to support the micro controller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.
Micro-controller ATmega328 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz

Buy Arduino Board from here-

Arduino Uno R3 ATmega328P ATMEGA16U2 Compatible with USB Cable

HC-SR04 Ultrasonic Sensor

The HC-SR04 ultrasonic sensor uses sonar to measure distance to an object. It offers excellent range accuracy and stable readings in an easy-to-use package. It operation is not affected by sunlight or black material like Sharp rangefinders are (soft materials like cloth can be difficult to detect). Module main technical parameters: 1.Working Voltage : 5V(DC) 2.Static current: Less than 2mA. 3.Output signal: Electric frequency signal, high level 5V, low level 0V. 4.Sensor angle: Not more than 15 degrees. 5.Detection distance: 2cm-450cm. 6.High precision: Up to 0.3cm 7.Input trigger signal: 10us TTL impulse 8.Echo signal : output TTL PWL signal Mode of connection: 1.VCC 2.trig(T) 3.echo(R) 4.GND The basic operation principle is below : use IO port TRIG to trigger ranging. It needs 10 us high level signal at least Module will send eight 40kHz square wave automatically, and will test if there is any signal returned. If there is signal returned, output will be high level signal via IO port ECHO. The duration of the high level signal is the time from transmitter to receiving with the ultrasonic. Testing distance = duration of high level*sound velocity(340m/s) / 2 You can use the above calculation to find the distance between the obstacle and the ultrasonic module.NOTE : The module has a blind spot of 2cm(very near). So obstacle held too closely will not be detected.

  HC-SR04 Ultrasonic Module Distance Measuring Transducer Sensor DC 5V

Shift Register 8-Bit - SN74HC595

The SN74HC595N is a simple 8-bit shift register IC. Simply put, this shift register is a device that allows additional inputs or outputs to be added to a microcontroller by converting data between parallel and serial formats. Your chosen microprocessor is able to communicate with the The SN74HC595N using serial information then gathers or outputs information in a parallel (multi-pin) format. Essentially it takes 8 bits from the serial input and then outputs them to 8 pins.

This small DIP packaged IC contains an 8-bit, serial-in parallel-out shift register that feeds an 8-bit D-type storage register with parallel 3-state outputs.

8-Bit Serial-In, Parallel-Out Shift
Wide Operating Voltage Range of 2 V to 6 V
High-Current 3-State Outputs Can Drive Up to 15 LSTTL Loads
Low Power Consumption: 80-μA
±6-mA Output Drive at 5 V

How To Make Traffic Light System with Pedestrian Crossing lights

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a p–n junction diode, which emits light when activated.When a suitable voltage is applied to the leads, electrons are able to recombine with electron holes within the device, releasing energy in the form of photons. This effect is called electroluminescence, and the color of the light (corresponding to the energy of the photon) is determined by the energy band gap of the semiconductor.
An LED is often small in area (less than 1 mm2) and integrated optical components may be used to shape its radiation pattern
Simple LED have two terminal one is Anode (+) and other is cathode (-).Two identify them just check the size of legs/terminal the shorter one will be cathode (-) and longer one is Anode (+).

Circuit Diagram:-
Distance Measuring LED's Bar Graph For Parking Sensor

Circuit Assembly:-
Distance Measuring LED's Bar Graph For Parking Sensor
Now Place Everything on the breadboard as shown in the image and then connect everything as shown in the circuit diagram or as following.

74HC595 8 Bit Shift Register - Arduino and LEDs

5V                              – Pin 10 and Pin 16
Ground                       – Pin 8 and Pin 13
IC Pin 11                                       
 - Arduino Pin 11
IC Pin 12                                       
 – Arduino Pin 12
IC Pin 14                                         
Arduino Pin 13
1st LED (Green Led)        
       – IC Pin 15  with Register
2nd LED(Green Led) 
to 7th LED   IC Pin 1 to IC Pin 6 with Register
8th LED (Last Red  Led)                -  IC Pin 9  with Register

Ultrasonic Sensor - Arduino
 – 5V
 – Arduino Pin 3
 – Arduino Pin 4
 – GND
Buzzer - Arduino
Black wire    – ground
Longer lead
( Red wire) – Arduino Pin 2 with Resistor

Distance Measuring LED's Bar Graph For Parking Sensor

/*Bar Graph Distance Meter 
 * by Sourabh Kumar 
 * Andro Root 
int buzzerPin = 2;   //buzzer
int clockPin = 11;  //shift register
int latchPin = 12; //shift register 
int dataPin = 13; //shift register  
int pingPin = 3; //Trig   
int inPin = 4;  //Echo   
int proximity=0;
int duration;
int distance;
byte possible_patterns[9] = {

void setup() 
  Serial.begin (9600); //Defult
  pinMode(inPin, INPUT);
  pinMode(pingPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);

void loop() 
  digitalWrite(latchPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);
  duration = pulseIn(inPin, HIGH);
  distance = (duration/2) / 29.1;
  proximity=map(distance, 0, 45, 8, 0);
  if (proximity <= 0){
  else if (proximity >= 1 && proximity <= 2){
    tone(buzzerPin, 350000, 200); 
  else if (proximity >= 3 && proximity <= 4){
    tone(buzzerPin, 200000, 200);
  else if (proximity >= 5 && proximity <= 6){
     tone(buzzerPin,5000, 200);
  else if (proximity >= 7 && proximity <= 8){
    tone(buzzerPin, 1000, 200);
  shiftOut(dataPin, clockPin, MSBFIRST, possible_patterns[proximity]);
  digitalWrite(latchPin, HIGH);

>>Some part of the above code is taken from Random Nerd Tutorials so for coding credit goes to them.<<
Final Result:-

Distance Measuring LED's Bar Graph For Parking Sensor
Distance Measuring LED's Bar Graph For Parking Sensor

So We have made a Parking Sensor or Distance Measuring LED's Bar Graph successfully . Fabricate the complete circuit and use it in Parking Area or in Car or at the door If something will be closer to it then it will warn you and show you distance with the help of Led.Lid will be switched on according to the distance between the object and ultrasonic sensor.If the object or obstacle will be at nearest distance then All LEDs will be switched on till Last Red leds and if the object is so far then green leds will glow up, Thus it will show the distance of object from the Ultrasonic Sensor.This is very easy project , i hope you will make your own Parking Sensor with the help of this tutorial.You can also make Some very cool Project with our tutorials some of them are:-

If you like our tutorial then please share your Post and like our Social Profiles.


Post a Comment

Join Us on Facebook