Tinker Board Forum

Full Version: L298N motor controller spining motor on asus board
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Guys 

I am totally newbie and am learning Robotics for the first times I brought L298N motor controller board  looking at the GPIO TinkerBoard Wiki page GPIO I have connected my wires as such

from L298N GND goes into Asus Tinker board pin 39 

for Motor1 the pin goes to 37/38 
for Motor2 the pint goes to 35/36

when I turn the Board on the motors starts spinning first the left side then the right side , when I run my code it executes and then goes back to its spining 

here is my code : 

    import sys
    import time
    import ASUS.GPIO as GPIO



    m1 = 38 #forward is working 
    m2 = 36

    GPIO.setup(m1, GPIO.OUT)
    GPIO.setup(m2, GPIO.OUT)

    def forward(x):
    GPIO.output(m1, GPIO.HIGH)
    print("Moving Forward")
    GPIO.output(m1, GPIO.LOW)

    def reverse(x):
    GPIO.output(m2, GPIO.HIGH)
    print("Moving Backward")
    GPIO.output(m2, GPIO.LOW)

    for x in xrange(1,2):

Any help would be very much appericated
Does anyone have any ideas on how to fix this ?

Could you draw your wiring diagram for us?
And what is the model of your L298N control board?
(maybe take a photo)

Because it looks like missed a lots of parts code.

Quote:missed 37 define
missed 35 define

which L298N GND connect to pin 39?
and where is the power source?

code example:
pin1 = 37;
pin2 = 38;
pin3 = 35;
pin4 = 36;

GPIO.setup(pin1, GPIO.OUT)
GPIO.setup(pin2, GPIO.OUT)
GPIO.setup(pin3, GPIO.OUT)
GPIO.setup(pin4, GPIO.OUT)

# m1
def m1_forward():
GPIO.output(pin1, GPIO.LOW)
GPIO.output(pin2, GPIO.HIGH)

def m1_reverse():
GPIO.output(pin1, GPIO.LOW)
GPIO.output(pin2, GPIO.HIGH)

# m2
def m2_forward():
GPIO.output(pin3, GPIO.LOW)
GPIO.output(pin4, GPIO.HIGH)

def m2_reverse():
GPIO.output(pin3, GPIO.LOW)
GPIO.output(pin4, GPIO.HIGH)