本文整理汇总了Python中RPi.GPIO.PUD_DOWN属性的典型用法代码示例。如果您正苦于以下问题:Python GPIO.PUD_DOWN属性的具体用法?Python GPIO.PUD_DOWN怎么用?Python GPIO.PUD_DOWN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类RPi.GPIO
的用法示例。
在下文中一共展示了GPIO.PUD_DOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self):
# Only for RPi3: set GPIOs to pulldown
global rpigpio
import RPi.GPIO as rpigpio
rpigpio.setmode(rpigpio.BCM)
# Layout of GPIOs for Raspberry demo
self._buttons = [16 , 6 , 5 , 24, 27]
self._LEDs = [20, 13, 12, 25, 22]
# Initialize them all
for pin in self._buttons:
rpigpio.setup(pin, rpigpio.IN, pull_up_down=rpigpio.PUD_DOWN)
for pin in self._LEDs:
rpigpio.setwarnings(False)
rpigpio.setup(pin, rpigpio.OUT)
super(UI_Raspberry, self).__init__()
示例2: init
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def init(self, mode=IN, pull=None):
"""Initialize the Pin"""
if mode is not None:
if mode == self.IN:
self._mode = self.IN
GPIO.setup(self.id, GPIO.IN)
elif mode == self.OUT:
self._mode = self.OUT
GPIO.setup(self.id, GPIO.OUT)
else:
raise RuntimeError("Invalid mode for pin: %s" % self.id)
if pull is not None:
if self._mode != self.IN:
raise RuntimeError("Cannot set pull resistor on output")
if pull == self.PULL_UP:
GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_UP)
elif pull == self.PULL_DOWN:
GPIO.setup(self.id, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
else:
raise RuntimeError("Invalid pull for pin: %s" % self.id)
示例3: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self, thread_id, notification_queue, sleeptime, pin = 27):
super().__init__(thread_id, notification_queue, sleeptime) # python 3 syntax only
self.pin = pin
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
示例4: setup
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(pecho, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(ptrig, GPIO.OUT)
GPIO.output(ptrig, 0)
示例5: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self, triggerpin):
GPIO.setup(triggerpin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
self.pin = triggerpin
示例6: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self):
GPIO.setmode(GPIO.BCM)
self.light = lightControl(self.light_pin, True)
self.redled = lightControl(self.red_pin)
self.yellowled = lightControl(self.yellow_pin)
self.motor = stepperControl()
GPIO.setup(self.trigger_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
self.motorstate = 0
self.smart_motor = False
self.smart_headroom = 25
self.triggertime = 0
self.qlen = 5
self.triggertimes = collections.deque([],self.qlen)
self.phototimes = collections.deque([],self.qlen)
示例7: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self, vcom=-1.5):
# check that we are root
self.early_exit = False
if geteuid() != 0:
print("***EPD controller must be run as root!***")
self.early_exit = True
exit()
self.spi = SPI()
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(Pins.HRDY, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(Pins.RESET, GPIO.OUT, initial=GPIO.HIGH)
# reset
GPIO.output(Pins.RESET, GPIO.LOW)
sleep(0.1)
GPIO.output(Pins.RESET, GPIO.HIGH)
self.width = None
self.height = None
self.img_buf_address = None
self.firmware_version = None
self.lut_version = None
self.update_system_info()
self._set_img_buf_base_addr(self.img_buf_address)
# enable I80 packed mode
self.write_register(Registers.I80CPCR, 0x1)
self.set_vcom(vcom)
示例8: halt_v3_pi
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def halt_v3_pi():
logger.info(_(u'Shutting down the Raspberry, Power Off (v3)'))
# Stoppe die Dienste
handle_service('WLANThermo', 'stop')
handle_service('WLANThermoPIT', 'stop')
# Schreibe aufs LCD
tmp_filename = get_random_filename('/var/www/tmp/display/wd')
while True:
try:
fw = open(tmp_filename, 'w')
fw.write(_(u'---- ATTENTION! ----;---- WLANThermo ----;is now shutting down;Bye-bye!'))
fw.flush()
os.fsync(fw.fileno())
fw.close()
os.rename(tmp_filename, '/var/www/tmp/display/wd')
except IndexError:
time.sleep(1)
continue
break
# Sende Abschaltkommando an den ATtiny
GPIO.setup(27, GPIO.OUT)
GPIO.output(27,True)
time.sleep(1)
GPIO.output(27,False)
time.sleep(1)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
# Fahre Betriebssystem herunter
bashCommand = 'sudo poweroff'
retcode = subprocess.Popen(bashCommand.split())
retcode.wait()
if retcode < 0:
logger.info(_(u'Terminated by signal'))
else:
logger.info(_(u'Child returned: ') + str(retcode))
示例9: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self, swmac, gwmac, ip, iface, wiface, dns, prx):
threading.Thread.__init__(self)
self.stoprequest = threading.Event()
self.switchmac = swmac
self.gwmac = gwmac
self.ip = ip
self.iface = iface
self.wiface = wiface
self.dns_srv = dns
self.prxlist = prx
GPIO.setmode(GPIO.BOARD)
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
示例10: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self):
print "setting up GPIO"
GPIO.setmode(GPIO.BOARD)
GPIO.setup(DeskCycle.PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP)
self.hitCount=0
pin2=38
GPIO.setup(pin2,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(pin2, GPIO.FALLING, callback=self.pin_2_event,bouncetime=100)
示例11: initialize_gpio
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def initialize_gpio():
GPIO.setmode(GPIO.BOARD)
GPIO.setup([R,G], GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(BUTTON, GPIO.FALLING, fan_the_flame, 250)
示例12: initialize_gpio
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def initialize_gpio():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LIGHTS, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
for i in range(4):
GPIO.add_event_detect(BUTTONS[i], GPIO.FALLING, verify_player_selection, 400 if use_sounds else 250)
示例13: initialize_gpio
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def initialize_gpio():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(Gmail.PIN, GPIO.OUT)
GPIO.setup(CHECK_NOW_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(CHECK_NOW_PIN, GPIO.RISING, callback=check_mail_now, bouncetime=1000)
示例14: read
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def read(environ, response, parameter = None):
status = "200 OK"
header = [
("Content-Type", "application/json"),
("Cache-Control", "no-store, no-cache, must-revalidate"),
("Expires", "0")
]
try:
pin = int(parameter[0])
mode = GPIO.PUD_UP
if len(parameter) > 1 and parameter[1] == "down" :
mode = GPIO.PUD_DOWN
GPIO.setup(pin, GPIO.IN, pull_up_down=mode)
result = GPIO.input(pin)
except Exception as e:
status = "400 Bad Request"
result = str(e)
response(status, header)
return [json.dumps(result).encode()]
示例15: __init__
# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_DOWN [as 别名]
def __init__(self, bus, pin_number, team):
self.bus = bus
self.pin = pin_number
self.team = team
if self.pin:
#GPIO.setup(self.pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(self.pin, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.add_event_detect(self.pin, GPIO.FALLING, callback=self.on_goal, bouncetime=10)
else:
logger.warn("Cannot init GoalDetector {0}, pin not specified".format(self.team))