Skip to content

Instantly share code, notes, and snippets.

@deepaksinghvi
Created August 10, 2014 13:51
Show Gist options
  • Save deepaksinghvi/2210803e14126dcb7986 to your computer and use it in GitHub Desktop.
Save deepaksinghvi/2210803e14126dcb7986 to your computer and use it in GitHub Desktop.
Program to control the DC motor using RaspberryPI and L298N Motor Controller
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