本文整理匯總了Python中gpio_pins.GPIO.setup方法的典型用法代碼示例。如果您正苦於以下問題:Python GPIO.setup方法的具體用法?Python GPIO.setup怎麽用?Python GPIO.setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gpio_pins.GPIO
的用法示例。
在下文中一共展示了GPIO.setup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PressureSender
# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import setup [as 別名]
################################################################################
# GPIO input pullup: #
################################################################################
from gpio_pins import GPIO as GPIO
try:
if gv.platform == 'pi': # If this will run on Raspberry Pi:
pin_pressure = 22
elif gv.platform == 'bo': # If this will run on Beagle Bone Black:
pin_pressure = "P9_17"
except AttributeError:
pass
try:
GPIO.setup(pin_pressure, GPIO.IN, pull_up_down=GPIO.PUD_UP)
except NameError:
pass
################################################################################
# Main function loop: #
################################################################################
class PressureSender(Thread):
def __init__(self):
Thread.__init__(self)
self.daemon = True
self.start()
self.status = ''
示例2:
# 需要導入模塊: from gpio_pins import GPIO [as 別名]
# 或者: from gpio_pins.GPIO import setup [as 別名]
################################################################################
# GPIO input pullup and output: #
################################################################################
from gpio_pins import GPIO as GPIO
try:
if gv.platform == 'pi': # If this will run on Raspberry Pi:
pin_power_ok = 16 # GPIO23
elif gv.platform == 'bo': # If this will run on Beagle Bone Black:
pin_power_ok = " "
except AttributeError:
pass
try:
GPIO.setup(pin_power_ok, GPIO.IN, pull_up_down=GPIO.PUD_UP)
except NameError:
pass
try:
if gv.platform == 'pi': # If this will run on Raspberry Pi:
pin_ups_down = 18 # GPIO24
elif gv.platform == 'bo': # If this will run on Beagle Bone Black:
pin_ups_down = " "
except AttributeError:
pass
try:
GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
GPIO.setup(pin_ups_down, GPIO.OUT)
GPIO.output(pin_ups_down, GPIO.LOW)