我最近购买了这些 步进电机和驱动器板中的一个 -我找不到如何将其连接到Raspberry Pi的任何文档-我正尝试使用 AdaFruit教程,尽管我已将所有连接正确地建立了。已连接gpio引脚(驱动板上的LED正常点亮,电动机不起作用)。
有谁知道我可能在哪里寻找有关如何将树莓派连接到步进电机的更多信息?
更新:2013年11月15日我的程序代码是这个
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
#enable_pin = 18
coil_A_1_pin = 4
coil_A_2_pin = 17
coil_B_1_pin = 23
coil_B_2_pin = 24
#GPIO.setup(enable_pin, GPIO.OUT)
GPIO.setup(coil_A_1_pin, GPIO.OUT)
GPIO.setup(coil_A_2_pin, GPIO.OUT)
GPIO.setup(coil_B_1_pin, GPIO.OUT)
GPIO.setup(coil_B_2_pin, GPIO.OUT)
#GPIO.output(enable_pin, 1)
def forward(delay, steps):
for i in range(0, steps):
setStep(1, 0, 1, 0)
setStep(0, 1, 1, 0)
setStep(0, 1, 0, 1)
setStep(1, 0, 0, 1)
def backwards(delay, steps):
for i in range(0, steps):
setStep(1, 0, 0, 1)
setStep(0, 1, 0, 1)
setStep(0, 1, 1, 0)
setStep(1, 0, 1, 0)
def setStep(w1, w2, w3, w4):
GPIO.output(coil_A_1_pin, w1)
GPIO.output(coil_A_2_pin, w2)
GPIO.output(coil_B_1_pin, w3)
GPIO.output(coil_B_2_pin, w4)
while True:
delay = raw_input("Delay between steps (milliseconds)?")
steps = raw_input("How many steps forward? ")
forward(int(delay) / 1000.0, int(steps))
steps = raw_input("How many steps backwards? ")
backwards(int(delay) / 1000.0, int(steps))
我的面包板看起来像这样
我的驱动板看起来像这样
我有
IN1 => GPIO 4
IN2 => GPIO 17
IN3 => GPIO 23
IN4 => GPIO 24