Arduino Mega 2560 Controlled Motor with Rotary Encoder Feedback
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit consists of an Arduino Mega 2560 microcontroller, a rotary encoder, an L293D motor driver, and a hobby gearmotor with a 48:1 gearbox. The Arduino Mega 2560 serves as the central control unit, interfacing with the rotary encoder for user input and controlling the motor driver to drive the gearmotor.
Component List
Arduino Mega 2560
- Description: A microcontroller board based on the ATmega2560.
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, AREF, SDA, SCL
Rotary Encoder
- Description: A device that converts the angular position or motion of a shaft to an analog or digital code.
- Pins: GND, +, SW, DT, CLK
L293D Motor Driver
- Description: A quadruple high-current half-H driver designed to drive inductive loads such as relays, solenoids, DC and bipolar stepping motors.
- Pins: enable 1, input 1, output 1, gnd, output 2, input 2, vs, vss, input 4, output 4, output 3, input 3, enable 2
Hobby Gearmotor with 48:1 Gearbox
- Description: A small DC motor with a 48:1 gearbox for increased torque.
- Pins: pin 1, pin 2
Wiring Details
Arduino Mega 2560
5V connected to:
- L293D Motor Driver (vs, vss)
- Rotary Encoder (+)
GND connected to:
- L293D Motor Driver (gnd)
- Rotary Encoder (GND)
D2 PWM connected to:
- Rotary Encoder (CLK)
D3 PWM connected to:
- Rotary Encoder (DT)
D4 PWM connected to:
- Rotary Encoder (SW)
D8 PWM connected to:
- L293D Motor Driver (input 1)
D9 PWM connected to:
- L293D Motor Driver (input 2)
D10 PWM connected to:
- L293D Motor Driver (enable 1)
Rotary Encoder
GND connected to:
- Arduino Mega 2560 (GND)
+ connected to:
- Arduino Mega 2560 (5V)
SW connected to:
- Arduino Mega 2560 (D4 PWM)
DT connected to:
- Arduino Mega 2560 (D3 PWM)
CLK connected to:
- Arduino Mega 2560 (D2 PWM)
L293D Motor Driver
vs connected to:
- Arduino Mega 2560 (5V)
vss connected to:
- Arduino Mega 2560 (5V)
gnd connected to:
- Arduino Mega 2560 (GND)
input 1 connected to:
- Arduino Mega 2560 (D8 PWM)
input 2 connected to:
- Arduino Mega 2560 (D9 PWM)
enable 1 connected to:
- Arduino Mega 2560 (D10 PWM)
output 1 connected to:
- Hobby Gearmotor with 48:1 Gearbox (pin 2)
output 2 connected to:
- Hobby Gearmotor with 48:1 Gearbox (pin 1)
Hobby Gearmotor with 48:1 Gearbox
pin 1 connected to:
- L293D Motor Driver (output 2)
pin 2 connected to:
- L293D Motor Driver (output 1)
Documented Code
Arduino Mega 2560 Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Additional Documentation (documentation.txt)
This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the code used in the Arduino Mega 2560.