Arduino parking sensor

Arduino parking sensor project

Welcome to a new Arduino project. In this tutorial we will see how to build an Arduino parking sensor whose beeps become faster as your hand gets closer. We will also review the materials used to build it, show the wiring diagram and share the code needed to control the ultrasonic sensor.

Materials used in the parking sensor

Below you can find the materials needed to build this Arduino parking sensor together with a brief description of each one. If you want to make the project yourself, you can click the images to visit a website where those materials are available.

Arduino UNO board: It is the brain of the project and controls all of its processes through the code you will find below.

Protoboard: A board with internally connected holes (pins) that we will use to make the project's electrical connections.

Ultrasonic module: It is responsible for sending and receiving sound signals, and it calculates the distance to nearby objects based on how long those signals take to return.

Passive buzzer: This component contains a membrane that vibrates when a voltage is applied to it.

Jumper wires: These wires have male or female pin ends that let us connect the different components used in the project.

Components needed for this project

If you want a much more detailed explanation of how to build this project from start to finish, including the code, the video below covers the full process in a clearer and more visual way. And if you enjoy this kind of content, do not forget to subscribe.

Arduino starter kit
Arduino starter kit
Arduino Uno board
Arduino Uno board
HC-SR04 ultrasonic sensor
HC-SR04 ultrasonic sensor
Buzzer
Buzzer
Male-to-female jumper wires
Male-to-female jumper wires
Protoboard
Protoboard

WE DEVELOP YOUR IDEA

Need help with a project?

RobotUNO project consulting
  • Prototyping and MVPs
  • Arduino and ESP32
  • PCB design
  • 3D part design
  • Bluetooth connectivity
  • Feasibility study
  • Cost optimization
  • Technical consulting
  • Internet of Things
  • Patent support

Arduino wiring diagram to build the parking sensor

One of the most important parts of assembling this parking sensor is wiring every component correctly. To avoid assembly mistakes or wrong connections, here is the wiring diagram used in this project. With this wiring setup, you can use the code at the end of the post without any modification.

Arduino parking sensor wiring diagram

Arduino code for the parking sensor

Below you can find the Arduino code developed specifically for this project. The pins used in the code are the same ones shown in the wiring diagram above.

If you want a more detailed explanation of the different parts of the code and how this sensor works, I recommend watching the video linked above.

If you have any questions about how to use or install the development environment used for Arduino, here is a link to how to download the Arduino IDE

//Canal de YouTube -> RobotUNO
//Sensor de aparcamiento con Arduino

int TRIG = 10;
int ECO = 9;
int LED = 3;
int DURACION;
int DISTANCIA;

void setup(){
  pinMode(TRIG, OUTPUT);
  pinMode(ECO, INPUT);
  pinMode(LED, OUTPUT);
  Serial.begin(9600); //Numero de bits por segundo = 9600
}

void loop(){
  digitalWrite(TRIG, HIGH);
  delay(1);
  digitalWrite(TRIG, LOW);
  DURACION = pulseIn(ECO, HIGH);
  DISTANCIA = DURACION / 58.2;   //Valor especificado por el fabricante
  Serial.println(DISTANCIA);
  delay(200);
  if(DISTANCIA<=20 && DISTANCIA >= 0){
    digitalWrite(LED, HIGH);
    delay(DISTANCIA * 10);
    digitalWrite(LED, LOW);
  }
}
Published in Arduino projects, Sensor projects, Home automation projects, Electronics projects.