[英]Keeping LED constantly on with BeagleBone black and python
I have a small circuit plugged into a Beaglebone Black,我有一个小电路插入 Beaglebone Black,
What I would like is to keep a white LED constantly on.我想要的是让白色 LED 一直亮着。
If I run the following code the LED turns on briefly ad then turns off again.如果我运行以下代码,LED 会短暂亮起,然后再次熄灭。
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P8_14", GPIO.OUT)
GPIO.output("P8_14", GPIO.HIGH)
I have tried the following:我尝试了以下方法:
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P8_14", GPIO.OUT)
while True:
GPIO.output("P8_14", GPIO.HIGH)
Which will keep it constantly on but I have a feeling its actually blinking to fast for me to see.这将使其一直亮着,但我有一种感觉,它实际上在快速闪烁以让我看到。 And if for example I have a bunch of code in the while loop then it blinks again (assuming the time.sleep(1)
represents code that takes a second to run):例如,如果我在 while 循环中有一堆代码,那么它再次闪烁(假设time.sleep(1)
表示需要一秒钟才能运行的代码):
GPIO.setup("P8_14", GPIO.OUT)
while True:
GPIO.output("P8_14", GPIO.HIGH)
time.sleep(1)
Is there anyway to say to a pin to be on constantly with Python ?无论如何要说一个引脚要经常使用 Python 吗?
Thanks for your help,谢谢你的帮助,
P8_14 -- this is digital Input/Output pin. P8_14——这是数字输入/输出引脚。 To setup a digital pin as an output, set the output value to HIGH, and then cleanup after you're done:要将数字引脚设置为输出,请将输出值设置为 HIGH,然后在完成后进行清理:
GPIO.setup("P8_10", GPIO.OUT)
GPIO.output("P8_10", GPIO.HIGH)
GPIO.cleanup()
For blink leds or turn it on use USR0, USR1, USR2 and USR3.对于闪烁 LED 或将其打开,请使用 USR0、USR1、USR2 和 USR3。
For blinking onboard leds try this example:对于闪烁的板载 LED,请尝试以下示例:
for i in range(4):
GPIO.setup("USR%d" % i, GPIO.OUT)
while True:
for i in range(4): # Turn Leds ON
GPIO.output("USR%d" % i, GPIO.HIGH)
time.sleep(1)
for i in range(4): # Turn Leds Off
GPIO.output("USR%d" % i, GPIO.LOW)
time.sleep(1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.