Theo Rossouw
Published

Vehicle Parking Sensor

Here is a very nice use of a sonar sensor and LCD - a parking sensor that can actually be useful.

BeginnerFull instructions provided1.5 hours3,571
Vehicle Parking Sensor

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Adafruit LCD back pack
×1
Buzzer
Buzzer
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Parking sensor schematic diagram

Trinket can work directly of 12 V
you will need Express PCB & Sch to view diagram, i did post a picture of it aswel

Code

Distance parking sensor with LCD

C/C++
Remember to edit the 'ZERO" distance for the size of your bumper and placement of sensor on your bumper
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> 

hd44780_I2Cexp lcd; 
const int LCD_ROWS = 2;
const int LCD_COLS = 16;

const int buzzerPin = 12;
const int trigPin = 13;
const int echoPin = 11;
long duration;
int distanceCm;

void setup()
{
  lcd.begin(LCD_COLS, LCD_ROWS);
    lcd.backlight();
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distanceCm = duration*0.034/2;

lcd.setCursor(0,1); 
lcd.backlight();
lcd.print("Distance: "); 
lcd.print(distanceCm); 
lcd.print(" cm");
delay(10);


if (distanceCm < 100){
  lcd.setCursor(0,0);
  lcd.print(" OBJECT WARNING");
  delay(500);
  lcd.clear();
  
}else{
  
  lcd.setCursor(0,0);
  lcd.print("   NO DANGER");
  delay(1000);
  lcd.clear();
}
if (distanceCm <= 18){
  digitalWrite(buzzerPin, HIGH);
  lcd.backlight();
  delay(500);
  digitalWrite(buzzerPin, LOW);
  lcd.noBacklight();
  delay(500);
}
}

Credits

Theo Rossouw

Theo Rossouw

0 projects • 20 followers
Hi i am an junior Electronics and Software engineer that works in Benoni South Africa for a company that develop long term battery solutions

Comments