You are on page 1of 7

Experiment Title.2.

Student Name: Avishek kumar UID: 21BCS9666


Branch: CSE Section/Group: 417A
Semester: 2nd Date of Performance:
Subject Name: BEEE Subject Code: 21ELH-101

1. Aim: To design simple DC motor control circuit

2. Apparatus: ARDUINO UNO, DC motor, L293D, connecting wires. Push button

3. THEORY

There are three different type of motors −


DC motor

Servo motor

Stepper motor
A DC motor (Direct Current motor) is the most common type of motor. DC motors normally have just
two leads, one positive and one negative. If you connect these two leads directly to a battery, the
motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.

Warning − Do not drive the motor directly from Arduino board pins. This may damage the board.

Use a driver Circuit or an IC.

We will divide this chapter into three parts −

Just make your motor


spin Control motor speed

Control the direction of the spin of DC motor

4.CIRCUIT DIAGRAM
5. PROCEDURE..
NOTE--Follow the circuit diagram and make the connections as shown in the image given below.

Spin ControlArduino Code

int motorPin = 3;

void setup() {
}

void loop() {

digitalWrite(motorPin, HIGH);

Code to Note

The transistor acts like a switch, controlling the power to the motor. Arduino pin 3 is used to turn the
transistor on and off and is given the name 'motorPin' in the sketch.

6.FULL PROGRAM CODE


#define button 8
#define pot 0
#define pwm1 9
#define pwm2 10

boolean motor_dir = 0;
int motor_speed;
void setup() {
pinMode(button, INPUT_PULLUP);
pinMode(pwm1, OUTPUT);
pinMode(pwm2, OUTPUT);
}

void loop() {
motor_speed = analogRead(pot) / 4;
if(motor_dir)
analogWrite(pwm1, motor_speed);
else
analogWrite(pwm2, motor_speed);
if(!digitalRead(button)){ // If direction button is pressed
while(!digitalRead(button)); // Wait until direction button released
motor_dir = !motor_dir; // Toggle direction variable
if(motor_dir)
digitalWrite(pwm2, 0);
else
digitalWrite(pwm1, 0);
}
}

7.RESULT
Designing of simple DC motor control circuit using arduino is verified after uploading the program.

Evaluation Grid:

Sr. No. Parameters Marks Obtained Maximum Marks


1. Worksheet completion including writing 10
learning objectives/Outcomes.(To be
submitted at the end of the day).
2. Post Lab Quiz Result. 5
3. Student Engagement in 5
Simulation/Demonstration/Performance
and Controls/Pre-Lab Questions.
Signature of Faculty (with Date): Total Marks Obtained:

You might also like