









For a DC motor with wheels, the pin configuration typically involves two terminals for motor connections. If used with a motor driver, the pin configuration will depend on the driver.
| Pin Name | Description |
|---|---|
| IN1 | Input pin 1 for controlling motor direction (connect to microcontroller) |
| IN2 | Input pin 2 for controlling motor direction (connect to microcontroller) |
| ENA | Enable pin for motor A (connect to PWM pin for speed control) |
| OUT1 | Output pin 1 connected to one terminal of the motor |
| OUT2 | Output pin 2 connected to the other terminal of the motor |
| VCC | Power supply for the motor (e.g., 5V or 12V, depending on motor specs) |
| GND | Ground connection |
Connecting the Motor and Wheels:
Wiring with an Arduino UNO:
Arduino Code Example:
// Motor and wheels control using L298N motor driver and Arduino UNO
const int IN1 = 9; // Motor direction control pin 1
const int IN2 = 8; // Motor direction control pin 2
const int ENA = 10; // Motor speed control (PWM pin)
void setup() {
pinMode(IN1, OUTPUT); // Set IN1 as output
pinMode(IN2, OUTPUT); // Set IN2 as output
pinMode(ENA, OUTPUT); // Set ENA as output
}
void loop() {
// Move forward
digitalWrite(IN1, HIGH); // Set IN1 high
digitalWrite(IN2, LOW); // Set IN2 low
analogWrite(ENA, 150); // Set speed (0-255)
delay(2000); // Move forward for 2 seconds
// Move backward
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, HIGH); // Set IN2 high
analogWrite(ENA, 150); // Set speed (0-255)
delay(2000); // Move backward for 2 seconds
// Stop
digitalWrite(IN1, LOW); // Set IN1 low
digitalWrite(IN2, LOW); // Set IN2 low
analogWrite(ENA, 0); // Set speed to 0
delay(2000); // Stop for 2 seconds
}
Important Considerations:
Motor not spinning:
Motor spinning in the wrong direction:
Motor speed is inconsistent:
Motor driver overheating:
Can I use a single power supply for both the Arduino and motor driver?
What type of wheels should I use for different surfaces?
Can I control multiple motors with one Arduino?
By following this documentation, you can effectively integrate and operate motor and wheels components in your projects.