Beagle Board - beagleboard.org
De Funct
Published © GPL3+

BeagleBone Black and L298 Motor Driver in Python

This is a small motor driver based around the L298 dual, H-bridge and the BeagleBone Black. It was typed up in Python.

EasyWork in progress1 hour1,769
BeagleBone Black and L298 Motor Driver in Python

Things used in this project

Hardware components

Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
BeagleBone Black
BeagleBoard.org BeagleBone Black
×1
DC motor (generic)
×2

Software apps and online services

Debian Stretch

Story

Read more

Schematics

Schematic of this specific Motor Driver from Open-Electronics.org

This is a nice driver...
L298 schematic pryjsfwnlt

Code

Motor Geaux, Motor Backwards, and Motor Stop...

Python
This makes one, single motor go forward, go backwards, and stops. Then, the software ends and the motor stops.
import Adafruit_BBIO.GPIO as GPIO
import time

Master_Pin =  "P9_21"
ln1 =         "P9_22"
ln2 =         "P9_12"

if __name__=="__main__":

    GPIO.setup(Master_Pin, GPIO.OUT)
    GPIO.output(Master_Pin, GPIO.LOW)

    GPIO.setup(ln1, GPIO.OUT)
    GPIO.setup(ln2, GPIO.OUT)

    GPIO.output(Master_Pin, GPIO.HIGH)
    GPIO.output(ln1, GPIO.HIGH)
    GPIO.output(ln2, GPIO.LOW)
    time.sleep(5)

    GPIO.output(Master_Pin, GPIO.HIGH)
    GPIO.output(ln1, GPIO.LOW)
    GPIO.output(ln2, GPIO.HIGH)
    time.sleep(5)
    print "I love your body Larry!"

    GPIO.output(Master_Pin, GPIO.LOW)

    GPIO.output(Master_Pin, GPIO.LOW)
    GPIO.cleanup()

RE: On flack, Making Two Motors Go and Do Stuff...

Python
This is the software to make two motors move around some. I hope to make things more accessible for other people soon. Enjoy...
import Adafruit_BBIO.GPIO as GPIO
import time

Master_Pin1 =  "P8_13"
ln1a =         "P8_14"
ln1b =         "P8_15"

Master_Pin2 =  "P8_16"
ln2a =         "P8_17"
ln2b =         "P8_18"

if __name__=="__main__":

    GPIO.setup(Master_Pin1, GPIO.OUT)
    GPIO.setup(Master_Pin2, GPIO.OUT)
    GPIO.output(Master_Pin1, GPIO.LOW)
    GPIO.output(Master_Pin2, GPIO.LOW)

    GPIO.output(Master_Pin1, GPIO.HIGH)
    GPIO.output(Master_Pin2, GPIO.HIGH)

    GPIO.setup(ln1a, GPIO.OUT)
    GPIO.setup(ln1b, GPIO.OUT)

    GPIO.setup(ln2a, GPIO.OUT)
    GPIO.setup(ln2b, GPIO.OUT)

    GPIO.output(ln1a, GPIO.HIGH)
    GPIO.output(ln1b, GPIO.LOW)
    GPIO.output(ln2a, GPIO.HIGH)
    GPIO.output(ln2b, GPIO.LOW)
    time.sleep(6)

    GPIO.output(ln1a, GPIO.HIGH)
    GPIO.output(ln1b, GPIO.HIGH)
    GPIO.output(ln2a, GPIO.HIGH)
    GPIO.output(ln2b, GPIO.HIGH)
    time.sleep(6)

    GPIO.output(ln1a, GPIO.LOW)
    GPIO.output(ln1b, GPIO.HIGH)
    GPIO.output(ln2a, GPIO.LOW)
    GPIO.output(ln2b, GPIO.HIGH)
    print ("I love your body Larry!")
    time.sleep(8)

    GPIO.output(ln1a, GPIO.LOW)
    GPIO.output(ln1b, GPIO.LOW)
    GPIO.output(ln2a, GPIO.LOW)
    GPIO.output(ln2b, GPIO.LOW)
    print ("Waka, Waka, Waka!")
    time.sleep(8)

    GPIO.output(Master_Pin1, GPIO.LOW)
    GPIO.output(Master_Pin2, GPIO.LOW)

    GPIO.cleanup()

Many Moons!

Just some ideas on getting up and running w/ the L298 and a motor driver from Open-Electronics.org.

Credits

De Funct

De Funct

8 projects • 7 followers
Stay there and someone will find you...

Comments

Add projectSign up / Login