EE-312 Assignment-4 Vedika Garg
EE-312 Assignment-4 Vedika Garg
Assignment 4
Submitted By – Vedika Garg
Roll No – 210102096
Code:
TinkerCAD Link: https://www.tinkercad.com/things/0CK0IORCfUo
Approach:
• Connect the GND (ground) pin of the Arduino to the GND pin of the relay module.
• Connect a digital pin on the Arduino (e.g., Pin 7) to the input pin of the relay module.
• Connect the common terminal (COM) of the relay module to the positive terminal of the
power supply for the motor.
• Connect the normally open (NO) terminal of the relay module to one terminal of the DC
motor.
• Connect the other terminal of the DC motor to the negative terminal of the power supply.
(b) Use L293D Motor Driver to operate DC Motor at a variable speed controlled by a
potentiometer.
Code:
TinkerCAD Link: https://www.tinkercad.com/things/0CK0IORCfUo
Approach:
• Connect the GND pin of the L293D to the GND of the power supply and the GND of the
Arduino.
• Connect the VCC1 pin of the L293D to the 5V output of the Arduino.
• Connect the VCC2 pin of the L293D to the power supply voltage (e.g., 9V for a 9V motor).
• Connect the motor terminals to the OUT1 and OUT2 pins for one direction control (e.g.,
OUT1 to motor's + and OUT2 to motor's -).
• Connect the ENABLE1 pin of the L293D to a PWM capable digital pin on the Arduino (e.g.,
Pin 3).
• Connect the wiper terminal of the potentiometer to an analog pin on the Arduino (e.g., A0).
• Connect one end of the potentiometer to 5V and the other end to GND.
• This code sets up the PWM-enabled pin to control the speed of the motor using the analogRead
value from the potentiometer. The potentiometer value is mapped to a range suitable for PWM (0-
255).
• Remember to adjust the pin numbers according to your setup. Also, ensure that your power
supply voltage matches the motor's specifications and that you are using appropriate safety
measures when working with electronics.
(c) Use L293D, DC Motor to simulate a 4-wheel Drive with 3 Digital and 1 analog input.
Inputs are to be used as follows:
1. Digital Input 000 -> Stop
2. 001 -> Forward
3. 010 -> Backward
4. 011 -> Right
5. 100 -> Left
6. Analog input to Control Speed
Code:
Approach:
• Connect the L293D pins VCC1, VCC2 to the 5V output of the Arduino.
• Connect the GND pins of the L293D to the GND of both the power supply and the Arduino.
• Connect the DC motors to OUT1, OUT2, OUT3, and OUT4 pins of the L293D for each wheel.
• Connect the ENABLE pins of the L293D to digital pins on the Arduino (e.g., Pins 3, 4, 5, 6).
• Connect the wiper terminal of the potentiometer to an analog pin on the Arduino (e.g., A0).
• Connect one end of the potentiometer to 5V and the other end to GND.
• Connect the digital input pins for direction control (e.g., Pins 7, 8, 9) to the appropriate pins on
the L293D for each motor.
• This code sets up the L293D motor driver and the input pins for direction control. It reads the
analog input from the potentiometer to control the speed and reads the digital inputs to
determine the direction of movement.
• Adjust the pin numbers and motor arrangement according to your setup. Be sure to match the
power supply voltage to your motor's specifications and observe safety precautions when working
with electronics.
(d) Integrate LCD Display with Q3 to Display movement and Speed of Bot Code
Approach:
• In addition to the components mentioned earlier, you'll need an LCD display module (e.g., 16x2
or 20x4) and the required libraries for controlling the LCD.
• Connect the appropriate pins of the LCD module to the Arduino according to the module's
pinout.
• Install and configure the required LCD library.
• In this code, the LiquidCrystal library is included, the LCD pins are configured, and the LCD
instance is created. Inside the loop() function, after determining the movement and speed of the
bot, the LCD display is updated to show the current movement and speed information.