Chart Lab
Chart Lab
2.DC Motor- A DC motor converts electrical energy (direct current) into mechanical rotation.
3. Jumper wires - To make connections between components on the breadboard.
4. USB cable - To connect the Arduino board to the computer for programming and power.
5. Power Supply - A 5V regulated power supply or battery pack to power the Arduino and LCD
6. Bread Board
DC Motor:
A DC motor is an engine that converts direct current into rotational motion. It uses electroma
gnetic forces generated by current flowing through coils and interacting with magnetic fields.
The most common types rely on permanent magnets and have a mechanism, often a comm
utator with brushes, to reverse the current direction in the rotating part, which keeps the mot
or spinning continuously.
Procedure:
Motor Driver Connection:
Connect motor driver's power supply pins (5V and GND) to Arduino's matching pins.
Connect motor terminals to motor driver's output pins.
Connect Arduino's digital pins to motor driver's control pins.
Code Functionality:
Setup:
Arduino Programming:
const int enablePin = 9;
const int in1Pin = 2;
const int in2Pin = 3;
void setup() {
pinMode(enablePin, OUTPUT);
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
Serial.begin(9600);
}
void forward() {
digitalWrite(in1Pin, HIGH);
digitalWrite(in2Pin, LOW);
}
void backward() {
digitalWrite(in1Pin, LOW);
digitalWrite(in2Pin, HIGH);
}
void stopMotor() {
analogWrite(enablePin, 0);
}
void loop() {
setSpeed(150);
forward();
delayMotor(1000);
backward();
delayMotor(1000);
stopMotor();
delayMotor(1000);
}
OUTPUT:
Conclusion: -
In conclusion, connecting a DC motor to your Arduino UNO opens doors to a world of interactive proje
cts. While the Arduino itself can't provide the muscle for most motors, a motor driver bridges the gap.
By incorporating a motor driver like the L293D on a breadboard, you can leverage the Arduino's contr
ol finesse to regulate the motor's speed and direction.