【问题标题】:How to get keyboard input in Python? [duplicate]如何在 Python 中获取键盘输入? [复制]
【发布时间】:2017-02-24 23:31:59
【问题描述】:

我正在为连接到 Raspberry Pi GPIO 的压电蜂鸣器编写 Python 脚本。听听我到目前为止得到了什么。

import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)

time = 0.001

try:
        while True:
            GPIO.output(24, 1)
            sleep(time)
            GPIO.output(24, 0)
            sleep(time)

except:
    GPIO.cleanup()
    print "GPIO Cleaned Up!"

我希望能够在“While True”循环运行时通过按键盘上的向上和向下箭头来更改时间变量。任何帮助将不胜感激!

编辑:如果它可以通过 ssh 工作,那就太好了。

【问题讨论】:

    标签: python python-3.x raspberry-pi gpio


    【解决方案1】:

    请参阅this link,它解释了如何在 Python 中读取击键。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      相关资源
      最近更新 更多