Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver2
14いいね 546回再生

How to make an Arduino Car ? Using L298N DC Motor Driver - Easy DIY Robot Car Project

In this easy Arduino Nano car project, I demonstrate how to build a simple robot car using the L298N DC motor driver and N20 gear motors. The video covers the wiring, components, and basic code to get your car moving forward and turning smoothly.

This beginner-friendly tutorial is perfect for those who want to learn about motor control with Arduino Nano and L298N driver modules. Follow along to create your own mini robot car step-by-step!

🔧 Components Used:
Arduino Nano
L298N Dual H-Bridge Motor Driver
N20 DC Gear Motors
Battery Pack
Jumper Wires
Custom platform

Don't forget to like, subscribe, and comment if you want more Arduino and robotics projects!

arduino, nano, l298n, robot, car, diy, arduino, car, n20, gear, motor, dc, motor, driver, arduino, motor, control, beginner, project, easy, robot, car, tutorial, motor, driver, l298n, diy, robotics, arduino, robotics, project, robot, car, build

CODE :

#define ENA 10 // Motor A speed control pin
#define IN1 9 // Motor A direction control pin 1
#define IN2 8 // Motor A direction control pin 2
#define ENB 5 // Motor B speed control pin
#define IN3 7 // Motor B direction control pin 1
#define IN4 6 // Motor B direction control pin 2

// Function prototypes
void driveMotors(int speedA, int speedB);
void controlMotors(int directionA, int directionB);
void stopMotors();

void setup() {
// Setting pin modes
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
}

void loop() {
controlMotors(1, 1);
driveMotors(50, 75); // Motor A and Motor B run

delay(3000); // Wait for 3 seconds

// First motor runs continuously
controlMotors(1, 1);
driveMotors(255, 0); // Motor A runs, Motor B stops

delay(1500); // Wait for 1.5 seconds

// Second motor stops
}

// Sets the speeds of motors A and B
void driveMotors(int speedA, int speedB) {
analogWrite(ENA, speedA);
analogWrite(ENB, speedB);
}

// Sets the directions of motors A and B
void controlMotors(int directionA, int directionB) {
digitalWrite(IN1, directionA);
digitalWrite(IN2, !directionA);
digitalWrite(IN3, directionB);
digitalWrite(IN4, !directionB);

コメント