This is an old revision of the document!


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 :

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 and a direction function pointer for flexibility (left/right).
  • Modular design using function pointers: Uses a struct to pass in the turn direction (left or right) as a function, so the same lateral_park code works for both sides.
  • 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

Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe Resurse Software şi Resurse Hardware.

pm/prj2025/eradu/daniel.afanasiuc.1748129723.txt.gz · Last modified: 2025/05/25 02:35 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