Goeduhub:- AI, ML, HADOOP, Python and IOT Training provider.
Register for Free Certified Workshop on AI & Machine Learning :: 26-01-2020 || Career options for aspiring CS/IT, ECE, EE or EIC or EEE Engineers
0 like 0 dislike
7 views

1 Answer

0 like 0 dislike
by (6.7k points)
selected by
 
Best answer

Introduction: 

          DC Motor is the equipment which converts electrical power to mechanical power. DC motors are fast and continuous rotation motors mainly used for anything that needs to rotate at a high rotation per minute (RPM). DC Motors are used in car wheels, fans etc.

In this project we will use L293D motor driver IC to control the motor and that allows the motor to rotate in both the direction. The L293D is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V.

L293D-pinout-IoT-Training-in-Jaipur

              The L293D motor IC uses two pins referred to as inputs to sense the desired direction of the output, and another pin called Enable to sense On/Off. So, in our code, with the Enable pin On, if we want the motor to spin forward, we'll set input 1 to 'True' or 'HIGH', and input 2 to 'False' or 'LOW'. And if we want it to spin backwards, we'll set input 1 to 'False" or 'LOW' and input 2 to 'True' or "HIGH'. If both inputs are True or both are False, the motor will not run. 

The motor needs about 400 mA current to start, so use external power. Don’t connect motor directly to Raspberry-PI’s GPIO pins, otherwise your PI will be damage.

L293D-Raspberry-IoT-Training-in-Jaipur

Connections:-

Motor with L293D to Raspberry-pi-IoT-Training-in-Jaipur

  1. Pin1 and Pin9 are "Enable" pins. If they pulled low (GND), then the outputs will be turned off regardless of the input states, stopping the motors.
  2. Pin4, Pin5, Pin12 and Pin13 are ground pins which should ideally be connected to Ground pin (Pin no. 6, 9, 14, 20, 25, 30, 34 or 39) of Raspberry-PI
  3. Pin2, Pin7, Pin10 and Pin15 are logic input pins. These are control pins which should be connected to Raspberry PI’s GPIO Pins. Pin2 and Pin7 control the first motor (left); Pin10 and Pin15 control the second motor(right).
  4. Pin3, Pin6, Pin11, and Pin14 are output pins. Tie Pin3 and Pin6 to the first motor, Pin11 and Pin14 to second motor.
  5. Pin16 powers the IC and it should be connected to +5 V Pin (Pin no. 2 or 4) of Raspberry-PI
  6. Pin8 powers the two motors and should be connected to positive lead of a secondary battery. As per the datasheet, supply voltage can be as high as 36 Volts.

Python Program:-

import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(5,GPIO.OUT)   #Left motor input A

GPIO.setup(7,GPIO.OUT)   #Left motor input B

GPIO.setup(11,GPIO.OUT)  #Right motor input A

GPIO.setup(13,GPIO.OUT)  #Right motor input B

GPIO.setup(40,GPIO.OUT)  # for enable

GPIO.setup(38,GPIO.OUT)  # for enable

GPIO.setwarnings(False)

i=0

while i<1:

        print("Rotating both motors in clockwise direction")

        GPIO.output(40,1)

        GPIO.output(38,1)

        GPIO.output(5,0)

        GPIO.output(7,1)

        GPIO.output(11,1)

        GPIO.output(13,0)

        time.sleep(5)     #five second delay

       print("Rotating both motors in anticlockwise direction")

        GPIO.output(5,1)

        GPIO.output(7,0)

        GPIO.output(11,0)

        GPIO.output(13,1)

        time.sleep(5)

        i=i+1

GPIO.output(38,0)

GPIO.output(40,0)

|| New Year Discount on summer training-2020 ||

20% OFF | on all summer training courses

|| Offer valid till 31-JAN-2020 (Extended Date) ||

Courses & Fee

  1. Augmented Reality & Virtual Reality - INR 15000/-
  2. AI, ML & Deep Learning - INR 12000/-
  3. Robotic Process Automation (RPA) - INR 12000/-
  4. Big Data HADOOP - INR 12,000/-
  5. Internet of Things (IoT) - INR 10,000/-
  6. Web development using python (Django) - INR 8000/-
  7. Industrial Automation (PLC-SCADA) - INR 8000/- 

Limited time offer !! Hurry up!!

[[ CALL - 07976731765 ]]

Register for Training

 Go to your Branch CSE or IT | ECE | EE, EIC or EEEMECE
 Know About Popular Colleges/Universities  List of IITsList of NITs | RTU-KOTA | Manipal University-Jaipur | JECRC University | Amity University Jaipur | BIT Mesra-Jaipur | MODY UNIVERSITY | LNMIIT-Jaipur | JK Lakshmipat | Banasthali Vidyapith | POORNIMA University
 Exams:   List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
Placements:  List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Online Free Training:  Artificial Intelligence(AI) & Machine Learning | Python Programming | Internet of Things-IoT | OpenCV (Open Source Computer Vision Library) | LINUX | Big Data : Hadoop | 
 Goeduhub
About Us | Contact Us   Social::   |  | 
...