Driving DC motor using Raspberry Pi GPIO , L293D driver and
Python.
Driving DC motor using Raspberry Pi GPIO , L293D driver and
Python.
Components required:
1)
Raspberry Pi
2)
L293D IC
3)
Breadboard
4)
DC Motor(s)
5)
Connecting wires
6)
Pi Cobbler, not mandatory though I have used in
my circuit.
Connection
Pi GPIO to L293D to DC Motor.
Pinout diagram of L293D IC
Connectivity
1
|
RPi
|
L293D
|
Motor
|
2
|
GPIO23 (16)
|
1A(2)
|
|
3
|
GPIO24(18)
|
1B(7)
|
|
4
|
GPIO25(22)
|
1E(1)
|
|
5
|
|
M1A
|
Terminal 1
|
6
|
|
M1B
|
Terminal 2
|
7
|
|
+VMotor to External Source
|
|
8
|
GND
|
GND
|
|
Python program to control the motor
import RPi.GPIO as gpio
from time import sleep
gpio.setmode(gpio.BOARD)
Motor1A = 16
Motor1b = 18
Motor1e = 22
gpio.setup(Motor1A, gpio.OUT)
gpio.setup(Motor1b, gpio.OUT)
gpio.setup(Motor1e, gpio.OUT)
gpio.output(Motor1A, gpio.HIGH)
gpio.output(Motor1b, gpio.LOW)
gpio.output(Motor1e, gpio.HIGH)
sleep(5)
# reverse
gpio.output(Motor1b, gpio.HIGH)
gpio.output(Motor1A, gpio.LOW)
sleep(5)
gpio.cleanup()
|
No comments:
Post a Comment