2 回答
TA贡献1824条经验 获得超8个赞
它不是已经显示在PyPI中了吗?
from inputs import get_key
def key_input():
while 1:
events = get_key()
for event in events:
print(event.ev_type, event.code, event.state)
if __name__ == '__main__':
key_input()
TA贡献1827条经验 获得超8个赞
这样对吗??对不起,我还不清楚
from inputs import get_key
import RPi.GPIO as GPIO
import Slush
import math
import time
from time import sleep
b = Slush.sBoard()
m = [Slush.Motor(0), Slush.Motor(1), Slush.Motor(2), Slush.Motor(3)]
m[0].setMaxSpeed(150)
m[1].setMaxSpeed(150)
m[2].setMaxSpeed(250)
m[3].setMaxSpeed(150)
m[0].setCurrent(150, 150, 150, 150)
m[1].setCurrent(100, 100, 100, 100)
m[2].setCurrent(150, 150, 150, 150)
m[3].setCurrent(100, 100, 100, 100)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 100)
pwm.start(0)
GPIO.output(18, 1)
while 1:
events = get_key()
for event in events:
if event.code == 'KEY_ENTER':
pwm.ChangeDutyCycle(1)
time.sleep(1)
m[1].goTo(750)
time.sleep(3)
m[0].goTo(750)
time.sleep(3)
pwm.ChangeDutyCycle(99)
time.sleep(1)
添加回答
举报