This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
L298N motor controller spining motor on asus board
#1
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

    mode=GPIO.getmode()

    GPIO.cleanup()

    m1 = 38 #forward is working 
    m2 = 36
    sleeptime=1


    #GPIO.setmode(GPIO.BCM) 
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(m1, GPIO.OUT)
    GPIO.setup(m2, GPIO.OUT)

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

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


    for x in xrange(1,2):
    forward(2);
    reverse(1);
    
    GPIO.cleanup()


Any help would be very much appericated
Reply
#2
Does anyone have any ideas on how to fix this ?
Reply
#3
Hi,

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.

e.g. 
Quote:missed 37 define
missed 35 define

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

code example:
Code:
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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)