A simple Arduino-based smart car controlled via an L298N motor driver. This project includes functions for moving the car forward, backward, turning left/right, and stopping.
- Arduino Board (Uno/Nano)
- L298N Motor Driver
- DC Motors (x2)
- Chassis & Wheels
- Power Supply (Battery)
| L298N Pin | Arduino Pin |
|---|---|
| IN1 | 3 |
| IN2 | 5 |
| IN3 | 6 |
| IN4 | 9 |
- Forward Movement: Moves the car forward by a specified distance (cm).
- Backward Movement: Moves the car backward by a specified distance (cm).
- Left/Right Turn: Rotates the car by a specified angle (degrees).
- Stop Function: Immediately stops all motor movements.
stopCar()β Stops all motors.forward(d)β Moves the car forward by distanced(cm).backward(d)β Moves the car backward by distanced(cm).turnRight(deg)β Turns the car right bydegdegrees.turnLeft(deg)β Turns the car left bydegdegrees.
- Upload the code to the Arduino board.
- The car performs a 360Β° left turn once in the
loop(). - Adjust
dt(delay time) anditr(iteration count) as needed.
-
Forward/Backward Delay:
delay = (distance / speed) * 1000
(Speed: ~132.8 cm/s forward, ~130.083 cm/s backward) -
Turning Delay:
delay = (degrees / rotation_rate) * 1000
(Rotation Rate: ~395Β°/s left, ~411Β°/s right)
This project is open-source under the MIT License.
Happy Building! ππ¨