我是编程世界的新手,我想用这段代码来移动一点伺服:
# Servo Control
# Servo Control
import time
import wiringpi
# use 'GPIO naming'
wiringpi.wiringPiSetupGpio()
# set #18 to be a PWM output
wiringpi.pinMode(18, wiringpi.GPIO.PWM_OUTPUT)
# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
# divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)
delay_period = 0.01
while True:
for pulse in range(50, 250, 1):
wiringpi.pwmWrite(18, pulse)
time.sleep(delay_period)
for pulse in range(250, 50, -1):
wiringpi.pwmWrite(18, pulse)
time.sleep(delay_period)
当我在空闲状态下运行这段代码时,出现以下错误:
Traceback (most recent call last):
File "/home/pi/servo.py", line 3, in <module>
import wiringpi
ImportError: No module named 'wiringpi'
我确实安装了wiringpi。我使用以下方法检查了它:
dpkg --get-selections
我在以下之间找到了它:
wireless-regdb
wireless-tools
wiringpi
wolfram-engine
wolframscript
请帮助您可以感谢,