Created
August 10, 2014 13:51
-
-
Save deepaksinghvi/2210803e14126dcb7986 to your computer and use it in GitHub Desktop.
Program to control the DC motor using RaspberryPI and L298N Motor Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
from time import sleep | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(13, GPIO.OUT) | |
GPIO.setup(15, GPIO.OUT) | |
def forward(x): | |
GPIO.output(13, GPIO.HIGH) | |
sleep(x) | |
GPIO.output(13, GPIO.LOW) | |
def reverse(x): | |
GPIO.output(15, GPIO.HIGH) | |
sleep(x) | |
GPIO.output(15, GPIO.LOW) | |
forward(3) | |
sleep(0.5) | |
reverse(3) | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment