You are on page 1of 5

Worksheet 2.

Student Name:Yash Gupta UID: 22MCA20948


Branch:UIC Section/Group: 4/A
Semester: 4 Date : 15/3/24
Subject Name:IOT Subject Code: 22CAH-751

1. Aim/Overview of the practical:


Design a Toy having Two wheels (DC Motors) using motor-driven IC and interface with Arduino. It will follow
certain conditions

a) Both wheels moving in the forward direction for 3 secs.

b) Both wheels will stop for 2 secs.

c) Both wheels will move in Backward direction for 3 Secs.

2. Hardware Requirements:
➢ 1 x Arduino Uno
➢ 1 x Breadboard
➢ 2 x DC Motor
➢ 1 x Battery
➢ 1x motor-driven IC
3. Software requirements:
Tinkercad
4. Theory (Related to IC293D Motor Driver IC):

Arduino Uno:
- Microcontroller board based on the ATmega328P chip.
- Acts as the central control unit, interfacing with sensors and controlling outputs.
Certainly, here are three concise points about the L293D motor driver IC:
H-Bridge Design: L293D utilizes H-bridge circuits to control the direction and speed of DC
motors effectively.

Current and Voltage Handling: L293D can manage currents up to 600mA per channel and
voltages up to 36V, making it suitable for a wide range of motor applications.

Built-in Protection: It features built-in diodes to safeguard the IC and other components from
voltage spikes when the motor stops, enhancing reliability.

4. Circuit Diagram (TinkerCad):


Case 1:
Case 2 :

Case 3:
Coding:
int enA = 6; // Enable pin for motor A (L293D)
int in1 = 2; // Input pin 1 for motor A
int in2 = 3; // Input pin 2 for motor A
// Motor B connections (connected to Arduino pins)
int enB = 10; // Enable pin for motor B (L293D)
int in3 = 4; // Input pin 1 for motor B
int in4 = 5; // Input pin 2 for motor B
void setup()
{
// Set all the motor control pins to outputs
pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);
pinMode(enA, OUTPUT);
pinMode(enB, OUTPUT);

// At Initial stage turn off both motors (set all control pins to LOW)
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
void loop()
{
// Set motors to maximum speed using analogWrite for pulse-width modulation
// For PWM maximum possible values are 0 to 255
analogWrite(enA, 255);
analogWrite(enB, 255);

//forward motor directions (Condition a)

digitalWrite(in1, HIGH); // Set in1 HIGH to drive motor A forward


digitalWrite(in2, LOW); // Set in2 LOW to control motor A direction (forward)
digitalWrite(in3, HIGH); // Set in3 HIGH to drive motor B forward
digitalWrite(in4, LOW); // Set in4 LOW to control motor B direction (forward)
delay(3000); // Wait for 3 seconds

// Stop motors (Condition b)


digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);

delay(2000); // Wait for 2 seconds

// Backward motor direction (Condition c)


digitalWrite(in1, LOW); // Set in1 LOW to control motor A direction (backward)
digitalWrite(in2, HIGH); // Set in2 HIGH to drive motor A backward
digitalWrite(in3, LOW); // Set in3 LOW to control motor B direction (backward)
digitalWrite(in4, HIGH); // Set in4 HIGH to drive motor B backward

delay(3000); // Wait for 3 seconds

5. Learning outcomes (What I have learnt):


1. Understanding the functionality of H-bridge circuits in motor control.
2. Proficiency in interfacing Arduino with motor driver ICs.
3. Knowledge of current and voltage considerations in motor driver selection.
4. Appreciation for built-in protection features in electronic components.

You might also like