Arduino-Controlled Dual DC Motor Robot with Rotary Encoder Feedback
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit is designed to control a pair of DC gearmotors using an Arduino UNO microcontroller and an L298N DC motor driver. Additionally, a rotary encoder is included to provide feedback on the motor's position or speed. The Arduino UNO interfaces with the L298N motor driver to control the direction and speed of the motors, and it also reads signals from the rotary encoder.
Component List
Gearmotor DC Wheels Left
- Description: A DC gearmotor used for the left wheel of a mobile platform.
- Pins: PIN1, PIN2
Gearmotor DC Wheels Right
- Description: A DC gearmotor used for the right wheel of a mobile platform.
- Pins: PIN1, PIN2
Arduino UNO
- Description: A microcontroller board based on the ATmega328P, used for controlling the various components in the circuit.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
L298N DC Motor Driver
- Description: A motor driver module capable of driving two DC motors or one stepper motor.
- Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
Rotary Encoder
- Description: An input device that provides feedback on rotation, typically used for precise control of angular position.
- Pins: SHEILD, B PHASE, 0V, VCC, A PHASE
Wiring Details
Gearmotor DC Wheels Left
- PIN1: Connected to OUT1 on the L298N DC motor driver.
- PIN2: Connected to OUT2 on the L298N DC motor driver.
Gearmotor DC Wheels Right
- PIN1: Connected to OUT3 on the L298N DC motor driver.
- PIN2: Connected to OUT4 on the L298N DC motor driver.
Arduino UNO
- 5V: Supplies power to the 5V pin on the L298N DC motor driver and the VCC pin on the Rotary Encoder.
- GND: Connected to the GND pin on the L298N DC motor driver and the 0V pin on the Rotary Encoder.
- D2: Connected to the A PHASE pin on the Rotary Encoder.
- D3: Connected to the B PHASE pin on the Rotary Encoder.
- D5: Connected to the ENA pin on the L298N DC motor driver.
- D6: Connected to the ENB pin on the L298N DC motor driver.
- D9: Connected to the IN1 pin on the L298N DC motor driver.
- D10: Connected to the IN2 pin on the L298N DC motor driver.
- D11: Connected to the IN3 pin on the L298N DC motor driver.
- D12: Connected to the IN4 pin on the L298N DC motor driver.
L298N DC Motor Driver
- 5V: Receives power from the 5V pin on the Arduino UNO.
- GND: Connected to the GND pin on the Arduino UNO.
- OUT1, OUT2: Drive the Gearmotor DC Wheels Left.
- OUT3, OUT4: Drive the Gearmotor DC Wheels Right.
- IN1-IN4: Receive control signals from the Arduino UNO digital pins D9-D12.
- ENA, ENB: Receive PWM signals from the Arduino UNO digital pins D5 and D6 for speed control.
Rotary Encoder
- VCC: Powered by the 5V pin on the Arduino UNO.
- 0V: Connected to the GND pin on the Arduino UNO.
- A PHASE: Connected to the D2 pin on the Arduino UNO.
- B PHASE: Connected to the D3 pin on the Arduino UNO.
Documented Code
Arduino UNO Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Note: The provided code is a template and does not contain any functional code to control the motors or read from the rotary encoder. The user is expected to fill in the setup and loop functions with the necessary code to implement the desired functionality.