Self-parking Car

Introduction

Project Overview: The project is a small car controlled by an Arduino that can park itself automatically using four distance sensors. The goal is to show how basic electronics can be used to create a simple self-parking system. I started with the idea of helping a car park safely in tight spaces.

What it does: It can park itself automatically when a button is pressed, using real-time distance measurements from four ultrasonic sensors (front, back, left, and right).

What is its purpose: The goal is to demonstrate how autonomous parking can be implemented in a simple and affordable way using basic electronic components. It shows how distance sensors, motors, and simple logic can be used to create useful automation.

What was the starting idea: I wanted to simulate the basic functionality of smart cars that can park themselves, but using only simple components that are easy for students or hobbyists to understand and build.

Why we believe it's useful: For others, it can serve as a starting point for more advanced robotics or automotive projects. For me, it helped improve my practical skills in programming and electronics.

Description

HARDWARE

SOFTWARE

Hardware Design

Components :

  • Arduino Uno/Arduino 101 – Quantity: 1 – Notes: Main Controller
  • L298N Motor Driver Module – Quantity: 1 – Notes: Drives 2 DC motors
  • DC Gear Motors (TT or N20) – Quantity: 2 – Notes: Drive rear wheels
  • Wheels – Quantity: 2 – Notes: Attach to DC motors
  • Ultrasonic Sensors (HC-SR04) – Quantity: 4 – Notes: For front, back, left, right distance
  • Push Button – Quantity: 1 – Notes: Starts the parking attempt
  • Red LED – Quantity: 1 – Notes: 1 for status
  • Green LED – Quantity: 1 – Notes: 1 for status
  • 220Ω Resistors – Quantity: 2 – Notes: For each LED to prevent overcurrent
  • Only if using Arduino 101: 1kΩ and 2kΩ Resistors – Quantity: 4 – Notes: For the voltage divider (from 5V to 3.3V) of the HC-SR04 sensors
  • Battery Pack (6V and 7.5V/9V Li-ion) – Quantity: 2 — To power motors and Arduino
  • Breadboard – Quantity: 1 – Notes: For organizing small components
  • Jumper Wires (M/M, M/F) – Quantity: 30+ – Notes: For all connections
  • 2WD Car Chassis – Quantity: 1 – Notes: Frame to hold everything
  • Caster Wheel – Quantity: 1 – Front support wheel

Electrical scheme :

Electrical table :

Component Arduino Pin(s) Power GND Notes
L298N Motor Driver D5 (ENA), D8 (IN1), D12 (IN2), D11 (IN3), D10 (IN4), D6 (ENB), 5V (5V) 5V - 12V GND ENA/ENB for speed (PWM), IN1-4 for direction; `JPI` jumper off so 5V pin works as logic input
DC Gear Motor 1 (Left) Controlled via IN1, IN2 (L298N) Connect to OUT1, OUT2 on L298N
DC Gear Motor 2 (Right) Controlled via IN3, IN4 (L298N) Connect to OUT3, OUT4 on L298N
Ultrasonic Sensor Front-Right D2 (Trig), A0 (Echo) 5V GND Use voltage divider on Echo if Arduino 101 (3.3V logic)
Ultrasonic Sensor Front-Left D3 (Trig), A1 (Echo) 5V GND Use voltage divider on Echo if Arduino 101 (3.3V logic)
Ultrasonic Sensor Back-Left D4 (Trig), A2 (Echo) 5V GND Use voltage divider on Echo if Arduino 101 (3.3V logic)
Ultrasonic Sensor Back-Right D7 (Trig), A3 (Echo) 5V GND Use voltage divider on Echo if Arduino 101 (3.3V logic)
Push Button D9 5V (pull-up) GND Using INPUT_PULLUP
Red LED A4 5V (via 220Ω) GND Status indicator
Green LED D13 5V (via 220Ω) GND Status indicator
Battery (Motors) 6V-12V to L298N `VCC` GND Powers motors through L298N
Battery (Arduino) Vin 7.5V/9V GND Powers Arduino Uno or 101
Breadboard

Software Design

IDE :

  • Arduino IDE
  • Platform: Arduino Uno/Arduino 101
  • Programming language: C/C++ with Arduino core

Data structures :

  • struct orientation_t: refers to the configuration (pins/functions) of a certain orientation used for parking

Algorithms :

  • Sensor-driven control loop: Continuously reads distance data from HC-SR04 ultrasonic sensors to make real-time movement decisions.
  • Threshold-based detection:
    • Determines whether parking is possible based on precise distance thresholds (≤10 cm) from front and back sensors.
    • Detects the end of an obstacle before initiating the turn.
    • Adjusts orientation using back sensor feedback.
  • LED-based feedback system: Provides user feedback via LEDs — green for successful parking, red for failure.

Pseudocode :

DEFINE struct Orientation:
  front_trigger_pin
  front_echo_pin
  back_trigger_pin
  back_echo_pin
  turn_function  // function pointer for turning left or right
  
FUNCTION readUltrasonic(trigger, echo):
  Send trigger pulse
  Measure echo pulse duration
  RETURN calculated distance
  
FUNCTION moveForward(speed):
  Set motors to move forward at given speed
  
FUNCTION moveBackward(speed):
  Set motors to move backward at given speed
  
FUNCTION turnLeft(speed):
  Set motors to turn left at given speed
  
FUNCTION turnRight(speed):
  Set motors to turn right at given speed
  
FUNCTION stopMotors():
  Stop all motors
 
FUNCTION lateralPark(orientation):
  Turn on green LED
  WHILE front distance ≤ 10 cm:
      Move backward slightly
      Recheck front distance
  
  WHILE back distance > 15 cm:
      Call orientation.turn_function(speed)  // turn left or right
      Recheck back distance
  
  WHILE front distance > 10 cm:
      Move backward slightly
      Recheck front distance
  
  Turn off green LED
  Blink green LED to indicate success
  
FUNCTION loop():
  IF button is pressed:
      Read all 4 distances (FL, FR, BL, BR)
      
      IF FL and BL ≤ 10 cm:
          Create Orientation with FL, BL, and turnRight
          Call lateralPark()
      
      ELSE IF FR and BR ≤ 10 cm:
          Create Orientation with FR, BR, and turnLeft
          Call lateralPark()
      
      ELSE:
          Turn on red LED (parking not possible)

Results

  • The robot can successfully perform parking on either side using ultrasonic sensors.
  • It detects obstacles, turns accurately, and adjusts its position automatically.
  • LEDs provide clear feedback: green for success, red for failure.

Conclusions

This project demonstrates a simple and effective autonomous parking system using ultrasonic sensors and motor control. With modular design and real-time feedback, the robot can detect space, align itself, and park laterally on either side.

Resources

pm/prj2025/eradu/daniel.afanasiuc.txt · Last modified: 2025/05/25 04:13 by daniel.afanasiuc
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0