Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Mega 2560-Based Autonomous Parking System with Ultrasonic Sensors and Motor Control

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560-Based Autonomous Parking System with Ultrasonic Sensors and Motor Control

Circuit Documentation

Summary

This document provides a detailed overview of a circuit designed for an auto-parking system. The system utilizes multiple HC-SR04 ultrasonic sensors for distance measurement, an Arduino Mega 2560 microcontroller for processing, an L293D motor driver shield for motor control, and optical encoder sensors for precise motor movement tracking. The circuit is programmed to detect parking spaces and maneuver a vehicle into the space using the sensors and motors.

Component List

HC-SR04 Ultrasonic Sensor

Arduino Mega 2560

Optical Encoder Sensor Module

DRIVER SHIELD L293D

Motor with Reducer

Comment

Wiring Details

HC-SR04 Ultrasonic Sensor 1

HC-SR04 Ultrasonic Sensor 2

HC-SR04 Ultrasonic Sensor 3

HC-SR04 Ultrasonic Sensor 4

Arduino Mega 2560

Optical Encoder Sensor Module

DRIVER SHIELD L293D

Motor with Reducer 1

Motor with Reducer 2

Motor with Reducer 3

Motor with Reducer 4

Code Documentation

#include <NewPing.h>      // For HC-SR04 sensors
#include <AFMotor.h>      // For L293D motor driver shield
#include <Encoder.h>      // For encoder support

// Define ultrasonic sensor pins
#define TRIG1 40
#define ECHO1 41
#define TRIG2 34
#define ECHO2 35
#define TRIG3 36
#define ECHO3 37
#define TRIG4 38
#define ECHO4 39

// Set max distance for HC-SR04 sensors (in cm)
#define MAX_DISTANCE 200

// Define motors
AF_DCMotor motor1(1); // Connects to M1
AF_DCMotor motor2(2); // Connects to M2
AF_DCMotor motor3(3); // Connects to M3
AF_DCMotor motor4(4); // Connects to M4

// Encoder pins (example: encoder on motor1 and motor2)
Encoder encoder1(2, 3); // Pins connected to encoder of Motor 1
Encoder encoder2(18, 19); // Pins connected to encoder of Motor 2

// Initialize ultrasonic sensors
NewPing sonarFront(TRIG1, ECHO1, MAX_DISTANCE);
NewPing sonarLeft(TRIG2, ECHO2, MAX_DISTANCE);
NewPing sonarRight(TRIG3, ECHO3, MAX_DISTANCE);
NewPing sonarBack(TRIG4, ECHO4, MAX_DISTANCE);

// Variables