I have a small circuit plugged into a Beaglebone Black,
What I would like is to keep a white LED constantly on.
If I run the following code the LED turns on briefly ad then turns off again.
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):
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 ?
Thanks for your help,
P8_14 -- this is digital Input/Output pin. To setup a digital pin as an output, set the output value to HIGH, and then cleanup after you're done:
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.
For blinking onboard leds try this example:
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.