當前位置: 首頁>>代碼示例>>Python>>正文


Python GPIO.output方法代碼示例

本文整理匯總了Python中Adafruit_BBIO.GPIO.output方法的典型用法代碼示例。如果您正苦於以下問題:Python GPIO.output方法的具體用法?Python GPIO.output怎麽用?Python GPIO.output使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Adafruit_BBIO.GPIO的用法示例。


在下文中一共展示了GPIO.output方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: distanceMeasurement

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def distanceMeasurement(TRIG,ECHO):
    pulseEnd = 0
    pulseStart = time.time()
    GPIO.output(TRIG, True)
    time.sleep(0.0001)
    GPIO.output(TRIG, False)

    while (GPIO.input(ECHO) == 0):# and (time.time()-pulseStart < 1):
        pulseStart = time.time()
    while GPIO.input(ECHO) == 1:
        pulseEnd = time.time()

    pulseDuration = pulseEnd - pulseStart
    #print pulseEnd- pulseStart
    distance = pulseDuration * 17150
    distance = round(distance, 2)
    return distance 
開發者ID:MXET,項目名稱:SCUTTLE,代碼行數:19,代碼來源:L1_ultrasonic.py

示例2: init

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [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) 
開發者ID:adafruit,項目名稱:Adafruit_Blinka,代碼行數:22,代碼來源:pin.py

示例3: value

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def value(self, val=None):
        """Set or return the Pin Value"""
        if val is not None:
            if val == self.LOW:
                self._value = val
                GPIO.output(self.id, val)
            elif val == self.HIGH:
                self._value = val
                GPIO.output(self.id, val)
            else:
                raise RuntimeError("Invalid value for pin")
            return None
        return GPIO.input(self.id)


# names in comments copied from
# https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/common.c#L73

# PocketBeagle
# P1_1 = SYS VIN        # VIN_AC 
開發者ID:adafruit,項目名稱:Adafruit_Blinka,代碼行數:22,代碼來源:pin.py

示例4: low

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def low(self):
        GPIO.output(self.port, GPIO.LOW) 
開發者ID:daq-tools,項目名稱:kotori,代碼行數:4,代碼來源:gpio.py

示例5: high

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def high(self):
        GPIO.output(self.port, GPIO.HIGH) 
開發者ID:daq-tools,項目名稱:kotori,代碼行數:4,代碼來源:gpio.py

示例6: set_enabled

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def set_enabled(self):
    GPIO.output(self.pin, GPIO.LOW) 
開發者ID:intelligent-agent,項目名稱:redeem,代碼行數:4,代碼來源:Enable.py

示例7: set_disabled

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def set_disabled(self):
    GPIO.output(self.pin, GPIO.HIGH) 
開發者ID:intelligent-agent,項目名稱:redeem,代碼行數:4,代碼來源:Enable.py

示例8: setMode

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def setMode(self, mode):
        SteppingMode.instance.mode = mode
        GPIO.output(SteppingMode.instance.m0, mode & 1 == 1) 
        GPIO.output(SteppingMode.instance.m1, mode & 2 == 2) 
        GPIO.output(SteppingMode.instance.m2, mode & 4 == 4) 
開發者ID:ericboehlke,項目名稱:BB-8,代碼行數:7,代碼來源:StepperMotor.py

示例9: forward

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def forward(self, rpm):
        GPIO.output(self.directionPin, GPIO.HIGH)
        self.setSpeed(rpm) 
開發者ID:ericboehlke,項目名稱:BB-8,代碼行數:5,代碼來源:StepperMotor.py

示例10: reverse

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def reverse(self, rpm):
        GPIO.output(self.directionPin, GPIO.LOW)
        self.setSpeed(rpm) 
開發者ID:ericboehlke,項目名稱:BB-8,代碼行數:5,代碼來源:StepperMotor.py

示例11: ledBlink

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def ledBlink(data):
  if data.data = true:
     GPIO.output(LED, GPIO.HIGH)
     time.sleep(0.5)
     GPIO.output(LED, GPIO.LOW)
     time.sleep(0.5) 
開發者ID:PacktPublishing,項目名稱:ROS-Robotics-Projects-SecondEdition,代碼行數:8,代碼來源:beagleboneblack_gpio.py

示例12: __init__

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def __init__(self, bus=0, device=0, speed=1000000, pin_rst=def_pin_rst,
            pin_ce=0, pin_irq=def_pin_irq, pin_mode = def_pin_mode):
        self.pin_rst = pin_rst
        self.pin_ce = pin_ce
        self.pin_irq = pin_irq

        self.spi = SPIClass()
        self.spi.open(bus, device)
        if board == RASPBERRY:
            self.spi.max_speed_hz = speed
        else:
            self.spi.mode = 0
            self.spi.msh = speed

        if pin_mode is not None:
            GPIO.setmode(pin_mode)
        if pin_rst != 0:
            GPIO.setup(pin_rst, GPIO.OUT)
            GPIO.output(pin_rst, 1)
        GPIO.setup(pin_irq, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.add_event_detect(pin_irq, GPIO.FALLING,
                callback=self.irq_callback)
        if pin_ce != 0:
            GPIO.setup(pin_ce, GPIO.OUT)
            GPIO.output(pin_ce, 1)
        self.init() 
開發者ID:ondryaso,項目名稱:pi-rc522,代碼行數:28,代碼來源:rfid.py

示例13: spi_transfer

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def spi_transfer(self, data):
        if self.pin_ce != 0:
            GPIO.output(self.pin_ce, 0)
        r = self.spi.xfer2(data)
        if self.pin_ce != 0:
            GPIO.output(self.pin_ce, 1)
        return r 
開發者ID:ondryaso,項目名稱:pi-rc522,代碼行數:9,代碼來源:rfid.py

示例14: _set_pin_state

# 需要導入模塊: from Adafruit_BBIO import GPIO [as 別名]
# 或者: from Adafruit_BBIO.GPIO import output [as 別名]
def _set_pin_state(self, pin, state):
        GPIO.output(pin.location, self.PIN_STATES[state]) 
開發者ID:pingo-io,項目名稱:pingo-py,代碼行數:4,代碼來源:bbb.py


注:本文中的Adafruit_BBIO.GPIO.output方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。