This shows you the differences between two versions of the page.
pm:prj2025:eradu:daniel.afanasiuc [2025/05/24 02:19] daniel.afanasiuc [Hardware Design] |
pm:prj2025:eradu:daniel.afanasiuc [2025/05/25 04:13] (current) daniel.afanasiuc [Resources] |
||
---|---|---|---|
Line 29: | Line 29: | ||
** Components **: | ** Components **: | ||
- | * Arduino/Genuino 101 -- Quantity: 1 -- Notes: Main Controller | + | * Arduino Uno/Arduino 101 -- Quantity: 1 -- Notes: Main Controller |
* L298N Motor Driver Module -- Quantity: 1 -- Notes: Drives 2 DC motors | * L298N Motor Driver Module -- Quantity: 1 -- Notes: Drives 2 DC motors | ||
* DC Gear Motors (TT or N20) -- Quantity: 2 -- Notes: Drive rear wheels | * DC Gear Motors (TT or N20) -- Quantity: 2 -- Notes: Drive rear wheels | ||
Line 38: | Line 38: | ||
* Green 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 | * 220Ω Resistors -- Quantity: 2 -- Notes: For each LED to prevent overcurrent | ||
- | * 1kΩ and 2kΩ Resistors -- Quantity: 4 -- Notes: For the voltage divider (from 5V to 3.3V) of the HC-SR04 sensors | + | * 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 | * Battery Pack (6V and 7.5V/9V Li-ion) -- Quantity: 2 --- To power motors and Arduino | ||
* Breadboard -- Quantity: 1 -- Notes: For organizing small components | * Breadboard -- Quantity: 1 -- Notes: For organizing small components | ||
Line 50: | Line 50: | ||
** Electrical table **: | ** 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** | — | — | — | — | | ||
Line 58: | Line 72: | ||
** IDE **: | ** IDE **: | ||
* Arduino IDE | * Arduino IDE | ||
- | * Platform: Arduino/Genuino 101 | + | * Platform: Arduino Uno/Arduino 101 |
* Programming language: C/C++ with Arduino core | * Programming language: C/C++ with Arduino core | ||
Line 69: | Line 83: | ||
* Determines whether parking is possible based on precise distance thresholds (≤10 cm) from front and back sensors. | * 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. | * 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). | + | * Adjusts orientation using back sensor feedback. |
- | * 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. | * LED-based feedback system: Provides user feedback via LEDs — green for successful parking, red for failure. | ||
Line 86: | Line 99: | ||
Measure echo pulse duration | Measure echo pulse duration | ||
RETURN calculated distance | RETURN calculated distance | ||
+ | | ||
FUNCTION moveForward(speed): | FUNCTION moveForward(speed): | ||
Set motors to move forward at given speed | Set motors to move forward at given speed | ||
+ | | ||
FUNCTION moveBackward(speed): | FUNCTION moveBackward(speed): | ||
Set motors to move backward at given speed | Set motors to move backward at given speed | ||
+ | | ||
FUNCTION turnLeft(speed): | FUNCTION turnLeft(speed): | ||
Set motors to turn left at given speed | Set motors to turn left at given speed | ||
+ | | ||
FUNCTION turnRight(speed): | FUNCTION turnRight(speed): | ||
Set motors to turn right at given speed | Set motors to turn right at given speed | ||
+ | | ||
FUNCTION stopMotors(): | FUNCTION stopMotors(): | ||
Stop all motors | Stop all motors | ||
+ | |||
FUNCTION lateralPark(orientation): | FUNCTION lateralPark(orientation): | ||
Turn on green LED | Turn on green LED | ||
Line 107: | Line 120: | ||
Move backward slightly | Move backward slightly | ||
Recheck front distance | Recheck front distance | ||
+ | | ||
WHILE back distance > 15 cm: | WHILE back distance > 15 cm: | ||
Call orientation.turn_function(speed) // turn left or right | Call orientation.turn_function(speed) // turn left or right | ||
Recheck back distance | Recheck back distance | ||
+ | | ||
WHILE front distance > 10 cm: | WHILE front distance > 10 cm: | ||
Move backward slightly | Move backward slightly | ||
Recheck front distance | Recheck front distance | ||
+ | | ||
Turn off green LED | Turn off green LED | ||
Blink green LED to indicate success | Blink green LED to indicate success | ||
+ | | ||
FUNCTION loop(): | FUNCTION loop(): | ||
IF button is pressed: | IF button is pressed: | ||
Read all 4 distances (FL, FR, BL, BR) | Read all 4 distances (FL, FR, BL, BR) | ||
+ | | ||
IF FL and BL ≤ 10 cm: | IF FL and BL ≤ 10 cm: | ||
Create Orientation with FL, BL, and turnRight | Create Orientation with FL, BL, and turnRight | ||
Call lateralPark() | Call lateralPark() | ||
+ | | ||
ELSE IF FR and BR ≤ 10 cm: | ELSE IF FR and BR ≤ 10 cm: | ||
Create Orientation with FR, BR, and turnLeft | Create Orientation with FR, BR, and turnLeft | ||
Call lateralPark() | Call lateralPark() | ||
+ | | ||
ELSE: | ELSE: | ||
Turn on red LED (parking not possible) | Turn on red LED (parking not possible) | ||
Line 148: | Line 161: | ||
===== Resources ===== | ===== Resources ===== | ||
- | <note> | + | Github: [[https://github.com/danielafanasiuc/Self-parking-Car]] |
- | Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. | + | |
- | </note> | + |