Arduino Mega 2560-Based Light-Sensing Motor Control System with Battery Power
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit involves an Arduino Mega 2560 microcontroller, multiple photocells (LDRs), resistors, potentiometers, a motor driver (L298N), and two hobby motors. The circuit is designed to read analog signals from the photocells and potentiometers, control the motors via the motor driver, and is powered by a 9V battery.
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, 6swdw
Motor amarillo motorreductor hobby
- Description: A small DC motor with a gearbox.
- Pins: vcc, GND
L298N DC motor driver
- Description: A dual H-Bridge motor driver.
- 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
Photocell (LDR)
- Description: A light-dependent resistor.
- Pins: pin 0, pin 1
Resistor
- Description: A 200 Ohm resistor.
- Pins: pin1, pin2
Potentiometer
- Description: A variable resistor.
- Pins: GND, Output, VCC
My battery case
- Description: A battery holder for a 9V battery.
- Pins: +, -
9V Battery
- Description: A 9V battery.
- Pins: +, -
Wiring Details
Arduino Mega 2560
5V connected to:
- Resistor pin1
- Potentiometer VCC
GND connected to:
- L298N DC motor driver GND
- My battery case -
- Photocell (LDR) pin 1
- Potentiometer GND
A0 connected to:
- Potentiometer Output
A1 connected to:
- Potentiometer Output
A2 connected to:
- Potentiometer Output
A3 connected to:
- Potentiometer Output
A8 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
A9 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
A10 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
A11 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
A12 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
A13 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
A14 connected to:
- Resistor pin2
- Photocell (LDR) pin 0
D2 PWM connected to:
- L298N DC motor driver ENA
D3 PWM connected to:
- L298N DC motor driver IN1
D4 PWM connected to:
- L298N DC motor driver IN2
D5 PWM connected to:
- L298N DC motor driver IN3
D6 PWM connected to:
- L298N DC motor driver IN4
D7 PWM connected to:
- L298N DC motor driver ENB
6swdw connected to:
- 9V Battery +
Motor amarillo motorreductor hobby
vcc connected to:
- L298N DC motor driver OUT4
- L298N DC motor driver OUT2
GND connected to:
- L298N DC motor driver OUT3
- L298N DC motor driver OUT1
L298N DC motor driver
- 12V connected to:
- My battery case +
Photocell (LDR)
pin 0 connected to:
- Resistor pin2
- Arduino Mega 2560 A8-A14
pin 1 connected to:
- Arduino Mega 2560 GND
Resistor
pin1 connected to:
- Arduino Mega 2560 5V
pin2 connected to:
- Photocell (LDR) pin 0
- Arduino Mega 2560 A8-A14
Potentiometer
GND connected to:
- Arduino Mega 2560 GND
Output connected to:
- Arduino Mega 2560 A0-A3
VCC connected to:
- Arduino Mega 2560 5V
My battery case
+ connected to:
- L298N DC motor driver 12V
- connected to:
- Arduino Mega 2560 GND
9V Battery
+ connected to:
- Arduino Mega 2560 6swdw
- connected to:
- Arduino Mega 2560 GND
Code Documentation
Arduino Mega 2560 Code
File Name: sketch.ino
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
File Name: documentation.txt
This documentation provides a comprehensive overview of the circuit, including a detailed component list, wiring details, and the code used in the Arduino Mega 2560 microcontroller.