0
一起此编程基于L293D电机驱动程序。
例如Pi 16,18,22中的引脚是与一侧电机相关的引脚。
它翩和pinB的用于打开在任松的方向使电机是在pin22与您的代码此错误代码与GPIO
from time import sleep
import thread
import RPi.GPIO as GPIO
class Motion:
#this class is used to define the different motion of the wheel.
def __init__(self,pinA,pinB,pinE):
GPIO.setmode(GPIO.BOARD)
Motor1A = pinA;
Motor1B = pinB;
Motor1E = pinE;
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1E,GPIO.OUT)
def forward(self):
print "Moving Forward"
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1E,GPIO.HIGH)
GPIO.cleanup()
sleep(2)
def backword(self):
print "Moving Backword"
GPIO.output(Motor1A,GPIO.LOW)
GPIO.output(Motor1B,GPIO.HIGH)
GPIO.output(Motor1E,GPIO.HIGH)
GPIO.cleanup()
sleep(2)
def stop(self):
print "No Movements, Stoped"
GPIO.output(Motor1E,GPIO.LOW)
GPIO.cleanup()
。格式化您的代码(请参阅https://stackoverflow.com/help/formatting)并提出明确的问题。这段代码应该做什么,哪些不起作用? PLS。阅读[问] – jps
好问题,_什么是错误?_。我看不到任何 – 2017-06-06 14:44:14