10-19-2017, 01:09 PM
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
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