当前位置: 首页>>代码示例>>Python>>正文


Python GPIO.IN属性代码示例

本文整理汇总了Python中RPi.GPIO.IN属性的典型用法代码示例。如果您正苦于以下问题:Python GPIO.IN属性的具体用法?Python GPIO.IN怎么用?Python GPIO.IN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在RPi.GPIO的用法示例。


在下文中一共展示了GPIO.IN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: writeByte

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def writeByte(self, data):
        for i in range(0, 8):
            IO.output(self.__Clkpin, IO.LOW)
            if(data & 0x01):
                IO.output(self.__Datapin, IO.HIGH)
            else:
                IO.output(self.__Datapin, IO.LOW)
            data = data >> 1
            IO.output(self.__Clkpin, IO.HIGH)

        # wait for ACK
        IO.output(self.__Clkpin, IO.LOW)
        IO.output(self.__Datapin, IO.HIGH)
        IO.output(self.__Clkpin, IO.HIGH)
        IO.setup(self.__Datapin, IO.IN)

        while(IO.input(self.__Datapin)):
            sleep(0.001)
            if(IO.input(self.__Datapin)):
                IO.setup(self.__Datapin, IO.OUT)
                IO.output(self.__Datapin, IO.LOW)
                IO.setup(self.__Datapin, IO.IN)
        IO.setup(self.__Datapin, IO.OUT) 
开发者ID:timwaizenegger,项目名称:raspberrypi-examples,代码行数:25,代码来源:tm1637.py

示例2: readUltrasonicSensor

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def readUltrasonicSensor():
    GPIO.setup(TRIGGER_PIN, GPIO.OUT)
    GPIO.setup(SENSOR_PIN, GPIO.IN)
    GPIO.output(TRIGGER_PIN, GPIO.LOW)
    time.sleep(0.3)
    GPIO.output(TRIGGER_PIN, True)
    time.sleep(0.00001)
    GPIO.output(TRIGGER_PIN, False)
    while GPIO.input(SENSOR_PIN) == 0:
        signaloff = time.time()
    while GPIO.input(SENSOR_PIN) == 1:
        signalon = time.time()
    timepassed = signalon - signaloff
    distance = timepassed * 17000
    if distance < threshold:
        return 1
    else:
        return 0 
开发者ID:nature1995,项目名称:ran-django-template,代码行数:20,代码来源:controller.py

示例3: saks_gpio_init

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
开发者ID:spoonysonny,项目名称:SAKS-SDK,代码行数:21,代码来源:sakshat.py

示例4: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def setup():
    """Setup piezo buzzer."""
    global _is_setup, pwm

    if _is_setup:
        return

    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup(BUZZER, GPIO.OUT)

    # Set up the PWM and then set the pin to input
    # to prevent the signal from being output.
    # Since starting/stopping PWM causes a segfault,
    # this is the only way to manage the buzzer.

    pwm = GPIO.PWM(BUZZER, 1)
    GPIO.setup(BUZZER, GPIO.IN)
    pwm.start(50)

    _is_setup = True 
开发者ID:pimoroni,项目名称:rainbow-hat,代码行数:23,代码来源:buzzer.py

示例5: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def __init__(self,
                 channel,
                 polarity=GPIO.FALLING,
                 pull_up_down=GPIO.PUD_UP,
                 debounce_time=0.08):
        if polarity not in [GPIO.FALLING, GPIO.RISING]:
            raise ValueError(
                'polarity must be one of: GPIO.FALLING or GPIO.RISING')

        self.channel = int(channel)
        self.polarity = polarity
        self.expected_value = polarity == GPIO.RISING
        self.debounce_time = debounce_time

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(channel, GPIO.IN, pull_up_down=pull_up_down)

        self.callback = None 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:21,代码来源:_button.py

示例6: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def setup():
    global _is_setup

    if _is_setup:
        return True

    atexit.register(_exit)

    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    GPIO.setup([DAT, CLK], GPIO.OUT)
    GPIO.setup(BUTTONS, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    for button in BUTTONS:
        GPIO.add_event_detect(button, GPIO.FALLING, callback=_handle_button, bouncetime=200)

    _is_setup = True 
开发者ID:pimoroni,项目名称:phat-beat,代码行数:19,代码来源:__init__.py

示例7: main

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def main():
    try:
        while True:
            for led in LEDS:
                for idx, pin in enumerate(led):
                    if pin == O:
                        GPIO.setup(PINS[idx], GPIO.IN)
                    else:
                        GPIO.setup(PINS[idx], GPIO.OUT)
                        GPIO.output(PINS[idx], pin)
                time.sleep(.1)
            
    except KeyboardInterrupt:
        pass

    finally:
        GPIO.cleanup() 
开发者ID:grantwinney,项目名称:52-Weeks-of-Pi,代码行数:19,代码来源:charlieplexing-6-on-3.py

示例8: setup_sensor

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def setup_sensor(self):
		try:
			GPIO.setup(self.gpio, GPIO.IN)
			GPIO.add_event_detect(self.gpio, GPIO.RISING, callback=self.cb_alarm, bouncetime=self.bouncetime)
		except ValueError as ve: # GPIO pin number or bouncetime is not in valid range
			logging.error("GPIOSensor: The given pin number or bouncetime is not in a valid range: %s" % ve)
			return
		logging.debug("GPIOSensor: Registered sensor at pin %s!" % self.gpio) 
开发者ID:SecPi,项目名称:SecPi,代码行数:10,代码来源:gpio_sensor.py

示例9: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [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) 
开发者ID:timwaizenegger,项目名称:raspberrypi-examples,代码行数:8,代码来源:flame.py

示例10: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [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) 
开发者ID:timwaizenegger,项目名称:raspberrypi-examples,代码行数:8,代码来源:ultrasonic-distance.py

示例11: initButtons

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def initButtons():
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(9, GPIO.IN, pull_up_down=GPIO.PUD_UP) 
开发者ID:timwaizenegger,项目名称:raspberrypi-examples,代码行数:8,代码来源:lcd-demo.py

示例12: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def __init__(self, triggerpin):
	GPIO.setup(triggerpin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
	self.pin = triggerpin 
开发者ID:jphfilm,项目名称:rpi-film-capture,代码行数:5,代码来源:steppertest.py

示例13: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [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) 
开发者ID:jphfilm,项目名称:rpi-film-capture,代码行数:16,代码来源:control.py

示例14: set_pin

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def set_pin(pin_index, pin_state):
    if pin_state == -1:
        GPIO.setup(pins[pin_index], GPIO.IN)
    else:
        GPIO.setup(pins[pin_index], GPIO.OUT)
        GPIO.output(pins[pin_index], pin_state) 
开发者ID:simonmonk,项目名称:raspberrypi_cookbook_ed2,代码行数:8,代码来源:charlieplexing.py

示例15: charge_time

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import IN [as 别名]
def charge_time():
    t1 = time.time()
    GPIO.setup(pin, GPIO.IN)
    while not GPIO.input(pin):
        # charge for 1ms
        GPIO.setup(pin, GPIO.OUT)
        GPIO.output(pin, True)
        time.sleep(0.001)
        # set to input to test again
        GPIO.setup(pin, GPIO.IN)  
        time.sleep(0.001) 
    t2 = time.time()
    return (t2 - t1) * 1000000

# Take an analog reading as the time taken to charge C 
开发者ID:simonmonk,项目名称:raspberrypi_cookbook_ed2,代码行数:17,代码来源:photoresistor_step.py


注:本文中的RPi.GPIO.IN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。