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


Python GPIO.OUT属性代码示例

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


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

示例1: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def __init__(self, id, params):
		super(Buzzer, self).__init__(id, params)
		try:
			self.duration = int(params["duration"])
			self.gpio_pin = int(params["gpio_pin"])
		except KeyError as ke: # if config parameters are missing in file
			logging.error("Buzzer: Wasn't able to initialize the device, it seems there is a config parameter missing: %s" % ke)
			self.corrupted = True
			return
		except ValueError as ve: # if a parameter can't be parsed as int
			logging.error("Buzzer: Wasn't able to initialize the device, please check your configuration: %s" % ve)
			self.corrupted = True
			return

		try:
			GPIO.setmode(GPIO.BCM)
			GPIO.setup(self.gpio_pin, GPIO.OUT)
		except ValueError as ve: # GPIO pin number is not in valid range
			logging.error("Buzzer: The given pin number is not in a valid range: %s" % ve)
			self.corrupted = True
			return
		logging.debug("Buzzer: Audio device initialized") 
开发者ID:SecPi,项目名称:SecPi,代码行数:24,代码来源:buzzer.py

示例2: writeByte

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [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

示例3: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def __init__(self):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)

        GPIO.setup(self.MotorFront1, GPIO.OUT)
        GPIO.setup(self.MotorFront2, GPIO.OUT)
        GPIO.setup(self.MotorFront, GPIO.OUT)
        GPIO.output(self.MotorFront, 0)

        GPIO.setup(self.MotorBack1, GPIO.OUT)
        GPIO.setup(self.MotorBack2, GPIO.OUT)
        GPIO.setup(self.MotorBack, GPIO.OUT)
        GPIO.output(self.MotorBack, 0)
        self.BackPWM = GPIO.PWM(self.MotorBack,100)
        self.BackPWM.start(0)
        self.BackPWM.ChangeDutyCycle(0)
        
        self.direction = 0 
开发者ID:yazeedalrubyli,项目名称:SDRC,代码行数:20,代码来源:drive.py

示例4: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def __init__(self):
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.dir_pin, GPIO.OUT)
        GPIO.setup(self.pulse_pin, GPIO.OUT)
        GPIO.setup(self.ms1_pin, GPIO.OUT)
        GPIO.setup(self.ms2_pin, GPIO.OUT)
        GPIO.setup(self.sleep_pin, GPIO.OUT)
        GPIO.setup(self.reset_pin, GPIO.OUT)
        dir=False
        GPIO.output(self.dir_pin, dir)
        GPIO.output(self.pulse_pin, False)
        GPIO.output(self.ms1_pin, True)
        GPIO.output(self.ms2_pin, False)
        GPIO.output(self.sleep_pin, False)
        GPIO.output(self.reset_pin, True)
        self.p1 = GPIO.PWM(self.pulse_pin, self.pulse_freq) 
开发者ID:jphfilm,项目名称:rpi-film-capture,代码行数:18,代码来源:control.py

示例5: InitHardware

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def InitHardware(self):

        # NOTE: This function assumes the underlying hardware is the LTE Cat 1 Pi Hat
        # http://wiki.seeedstudio.com/LTE_Cat_1_Pi_HAT/

        try:
            self.power_pin = 29
            self.reset_pin = 31
            GPIO.setmode(GPIO.BOARD)
            GPIO.setwarnings(False)
            GPIO.setup(self.power_pin, GPIO.OUT) # Setup module power pin
            GPIO.setup(self.reset_pin, GPIO.OUT) # Setup module reset pin
            GPIO.output(self.power_pin, False)
            GPIO.output(self.reset_pin, False)

            return self.PowerUp()
        except Exception as e1:
            self.LogErrorLine("Error in LTEPiHat:InitHardware: " + str(e1))
            return False
    #------------------LTEPiHat::PowerDown------------------------------------- 
开发者ID:jgyates,项目名称:genmon,代码行数:22,代码来源:mymodem.py

示例6: readUltrasonicSensor

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [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

示例7: saks_gpio_init

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [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

示例8: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [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

示例9: note

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def note(frequency, duration=1.0):
    """Play a single note.

    :param frequency: Musical frequency in hertz
    :param duration: Optional duration in seconds, use None to sustain note

    """
    global _timeout

    setup()

    if frequency <= 0:
        raise ValueError("Frequency must be > 0")

    if duration is not None and duration <= 0:
        raise ValueError("Duration must be > 0")

    clear_timeout()

    pwm.ChangeFrequency(frequency)
    GPIO.setup(BUZZER, GPIO.OUT)

    if duration is not None and duration > 0:
        _timeout = Timer(duration, stop)
        _timeout.start() 
开发者ID:pimoroni,项目名称:rainbow-hat,代码行数:27,代码来源:buzzer.py

示例10: show

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def show():
    """Output the buffer."""
    global _gpio_setup

    if not _gpio_setup:
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup([DAT, CLK, CS], GPIO.OUT)
        _gpio_setup = True

    GPIO.output(CS, 0)
    _sof()

    for pixel in pixels:
        r, g, b, brightness = pixel
        _write_byte(0b11100000 | brightness)
        _write_byte(b)
        _write_byte(g)
        _write_byte(r)

    _eof()
    GPIO.output(CS, 1) 
开发者ID:pimoroni,项目名称:rainbow-hat,代码行数:24,代码来源:apa102.py

示例11: set_74HC595_pins

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def set_74HC595_pins(self, DIR_LATCH, DIR_CLK, DIR_SER):
        """
        Set PINs used on Raspberry Pi to connect with 74HC595 module on
        Arduino Motor Shield

        :param int DIR_LATCH: LATCH PIN number
        :param int DIR_CLK: CLK PIN number
        :param int DIR_SER: SER  PIN number
        """
        self._DIR_LATCH = DIR_LATCH
        self._DIR_CLK = DIR_CLK
        self._DIR_SER = DIR_SER

        GPIO.setup(self._DIR_LATCH, GPIO.OUT)
        GPIO.setup(self._DIR_CLK, GPIO.OUT)
        GPIO.setup(self._DIR_SER, GPIO.OUT) 
开发者ID:lipoja,项目名称:AMSpi,代码行数:18,代码来源:AMSpi.py

示例12: init_process

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def init_process():
	print " "
	print "MSG - [S100, T110 CO2 Sensor Driver on RASPI2, Please check log file : ", LOG_PATH
	print "MSG - now starting to read SERIAL PORT"
	print " "
	# HW setup, GPIO
	GPIO.setwarnings(False)
	GPIO.cleanup()
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(18, GPIO.OUT)
	GPIO.setup(23, GPIO.OUT)
	GPIO.setup(24, GPIO.OUT)
	GPIO.setup(25, GPIO.OUT)
	logger.info(' *start* GPIO all set, trying to open serial port, SW starting ')
	rledAllOn()

######################################################################
# START Here. Main
######################################################################

# set logger file 
开发者ID:jeonghoonkang,项目名称:BerePi,代码行数:23,代码来源:co2_t110.py

示例13: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def __init__(self, left_p=13, right_p=15, forward_p=12, backward_p=11,
                 apply_time=0.3, wait_time=0):
        self.left_p = left_p
        self.right_p = right_p
        self.forward_p = forward_p
        self.backward_p = backward_p
        self.apply_time = apply_time
        self.wait_time = wait_time

        print("Setting up GPIO pins.")
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(self.backward_p, GPIO.OUT)  # Backwards.
        GPIO.setup(self.forward_p, GPIO.OUT)  # Forwards.
        GPIO.setup(self.left_p, GPIO.OUT)  # Left.
        GPIO.setup(self.right_p, GPIO.OUT)  # Right.

        # Reset in case they're still on from before.
        GPIO.output(self.backward_p, 0)
        GPIO.output(self.forward_p, 0)
        GPIO.output(self.left_p, 0)
        GPIO.output(self.right_p, 0) 
开发者ID:harvitronix,项目名称:rl-rc-car,代码行数:23,代码来源:rccar.py

示例14: write

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [as 别名]
def write(self, reason, value):
        status = True

        if reason == 'OUT':
            GPIO.output(PIN_OUT, value)
        elif reason == 'TRIG':
            GPIO.output(PIN_OUT, GPIO.HIGH)
            time.sleep(0.1)
            GPIO.output(PIN_OUT, GPIO.LOW)
            value = 0
        elif reason == 'PWM':
            if value == 0:
                self.pwm.stop()
            else:
                self.pwm.start(self.getParam('DC'))
        elif reason == 'DC':
            self.pwm.ChangeDutyCycle(value)
        elif reason == 'FREQ':
            self.pwm.ChangeFrequency(value)
        else:
            status = False

        if status:
            self.setParam(reason, value)
        return status 
开发者ID:paulscherrerinstitute,项目名称:pcaspy,代码行数:27,代码来源:rpi_gpio.py

示例15: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import OUT [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


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