









For a typical DC motor with two terminals:
| Pin Name | Description |
|---|---|
| V+ | Positive terminal for motor power |
| V- | Negative terminal for motor power |
For a stepper motor with four wires:
| Pin Name | Description |
|---|---|
| A+ | Coil A positive terminal |
| A- | Coil A negative terminal |
| B+ | Coil B positive terminal |
| B- | Coil B negative terminal |
Connecting a DC Motor:
Connecting a Stepper Motor:
Attaching Wheels:
// Example code to control a DC motor using an L298N motor driver
// Connect IN1 and IN2 of the motor driver to Arduino pins 9 and 10
#define IN1 9 // Motor driver input pin 1
#define IN2 10 // Motor driver input pin 2
void setup() {
pinMode(IN1, OUTPUT); // Set IN1 as output
pinMode(IN2, OUTPUT); // Set IN2 as output
}
void loop() {
// Rotate motor forward
digitalWrite(IN1, HIGH); // Set IN1 high
digitalWrite(IN2, LOW); // Set IN2 low
delay(2000); // Run motor for 2 seconds
// Stop motor
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, LOW); // Set IN2 low
delay(1000); // Wait for 1 second
// Rotate motor backward
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, HIGH); // Set IN2 high
delay(2000); // Run motor for 2 seconds
// Stop motor
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, LOW); // Set IN2 low
delay(1000); // Wait for 1 second
}
Motor Not Spinning:
Motor Spins in One Direction Only:
Motor Overheating:
Wheels Slipping: