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
2 views

1 Answer

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

L293D motor driver IC is used to control the DC Motor and that allows the motor to rotate in both the direction. 2 DC Motors can be controlled with a single L293D motor driver IC as describe in DC Motor Control With Raspberry Pi and L293D. Here we are using single motor to understand the concept of PWM.

PWM (Pulse Width Modulation) concept is used to control the speed of Motor.

Python Program


import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(5,GPIO.OUT) #Motor input A for clockwise direction

GPIO.setup(7,GPIO.OUT) #Motor input B for anticlockwise direction

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

GPIO.setwarnings(False)

i=0

pwm=GPIO.PWM(40,100) #Apply PWM to enable PIN (PIN no. 40 here)

pwm.start(0) #Start PWM with 0 Duty Cycle.

while i<1:

        for x in range(0,100,10):

                pwm.ChangeDutyCycle(x) # increase duty cycle or motor speed from 0 to 100 by  the interval of 10

                print("Duty_Cycle or motor speed is:",x)

                print("Rotating motor in clockwise direction with increase in speed by the interval  of 10")

                GPIO.output(5,0)

                GPIO.output(7,1)

                time.sleep(5)     #Five second delay

        for x in range(100,0,-10):

                pwm.ChangeDutyCycle(x) # decrease duty cycle or motor speed from 100 to 0 by the interval of 10

                print("Rotating Motor in anticlockwise direction with decrease in speed by the interval of 10")

                GPIO.output(5,0)

                GPIO.output(7,1)

                time.sleep(5)     #Five second delay

         i=i+1


|| 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::   |  | 
...