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


Python GPIO.output方法代码示例

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


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

示例1: buzz

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def buzz(self, duration):
		logging.debug("Buzzer: Trying to make some noise")
		start_time = time.time()
		state = True
		while (time.time() - start_time) < duration:
			GPIO.output(self.gpio_pin, state)
			if state:
				state = False
				time.sleep(0.5)
			else:
				state = True
				time.sleep(0.05)
		
		state = False
		GPIO.output(self.gpio_pin, state)
		logging.debug("Buzzer: Finished making noise") 
开发者ID:SecPi,项目名称:SecPi,代码行数:18,代码来源:buzzer.py

示例2: getValue

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def getValue():
	GPIO.output(ptrig, 0)
	time.sleep(0.1)
	GPIO.output(ptrig, 1)
	time.sleep(0.00001)
	GPIO.output(ptrig, 0)
	
	
	while(0 == GPIO.input(pecho)):
		start = time.time()
	while(1 == GPIO.input(pecho)):
		end = time.time()
		

	delay = (end - start) * 1000 * 1000
	time.sleep(0.1)
	distance = (delay / 58.0)
	if 2 < distance < 400: # working interval
		print("distance: %0.1f cm" % distance) 
开发者ID:timwaizenegger,项目名称:raspberrypi-examples,代码行数:21,代码来源:ultrasonic-distance.py

示例3: writeByte

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

示例4: __init__

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

示例5: pulsetest

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def pulsetest():
	dir=True
	for freq in [200, 400, 800, 1000]:
		halfpulse=.5/freq
#	for j in range(0,i):
		logging.debug("start")
		for i in range(0,1600):
			GPIO.output(pulse_pin, True)
			time.sleep(halfpulse)
			GPIO.output(pulse_pin, False)
			time.sleep(halfpulse)
		logging.debug("stop")
		dir=not dir
		GPIO.output(dir_pin, dir)
		time.sleep(.5)
#	logging.debug(i) 
开发者ID:jphfilm,项目名称:rpi-film-capture,代码行数:18,代码来源:steppertest.py

示例6: __init__

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

示例7: power_down

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def power_down(self):
        # Wait for and get the Read Lock, incase another thread is already
        # driving the HX711 serial interface.
        self.readLock.acquire()

        # Cause a rising edge on HX711 Digital Serial Clock (PD_SCK).  We then
        # leave it held up and wait 100 us.  After 60us the HX711 should be
        # powered down.
        GPIO.output(self.PD_SCK, False)
        GPIO.output(self.PD_SCK, True)

        time.sleep(0.0001)

        # Release the Read Lock, now that we've finished driving the HX711
        # serial interface.
        self.readLock.release() 
开发者ID:tatobari,项目名称:hx711py,代码行数:18,代码来源:hx711.py

示例8: power_up

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def power_up(self):
        # Wait for and get the Read Lock, incase another thread is already
        # driving the HX711 serial interface.
        self.readLock.acquire()

        # Lower the HX711 Digital Serial Clock (PD_SCK) line.
        GPIO.output(self.PD_SCK, False)

        # Wait 100 us for the HX711 to power back up.
        time.sleep(0.0001)

        # Release the Read Lock, now that we've finished driving the HX711
        # serial interface.
        self.readLock.release()

        # HX711 will now be defaulted to Channel A with gain of 128.  If this
        # isn't what client software has requested from us, take a sample and
        # throw it away, so that next sample from the HX711 will be from the
        # correct channel/gain.
        if self.get_gain() != 128:
            self.readRawBytes() 
开发者ID:tatobari,项目名称:hx711py,代码行数:23,代码来源:hx711.py

示例9: InitHardware

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

示例10: EnableRTSCTS

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

        try:
            process = Popen(['rpirtscts', 'on'], stdout=PIPE)
            output, _error = process.communicate()
            if _error == None:
                return True
            else:
                self.LogError("Error running rpirtscts in EnableRTSCTS: " + str(_error) )
                return False
        except Exception as e1:
            self.LogErrorLine("Error in EnableRTSCTS: " + str(e1))
            self.LogError("Output: " + str(output))
            self.LogError("Error: " + str(_error))
            return False

    #------------------LTEPiHat::DisableRTSCTS---------------------------------- 
开发者ID:jgyates,项目名称:genmon,代码行数:19,代码来源:mymodem.py

示例11: DisableRTSCTS

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

        try:
            process = Popen(['rpirtscts', 'off'], stdout=PIPE)
            output, _error = process.communicate()
            if _error == None:
                return True
            else:
                self.LogError("Error running rpirtscts in DisableRTSCTS: " + str(_error) )
                return False
        except Exception as e1:
            self.LogErrorLine("Error in DisableRTSCTS: " + str(e1))
            self.LogError("Output: " + str(output))
            self.LogError("Error: " + str(_error))
            return False

    #------------------LTEPiHat::Close------------------------------------------ 
开发者ID:jgyates,项目名称:genmon,代码行数:19,代码来源:mymodem.py

示例12: readUltrasonicSensor

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

示例13: flush_bit

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def flush_bit(self, sel, num, dp):
        if num == '#':
            num = 10
        elif num == '-':
            num = 11
        else:
            num = int(num)

        GPIO.output(self.__pins['sel'][sel], self.__real_true)
        n = self.__number_code[num]

        if dp:
            n = n | 10000000

        for i in range(8):
            if (n & (1 << i)):
                GPIO.output(self.__pins['seg'][i], self.__real_true)

        GPIO.output(self.__pins['sel'][sel], not self.__real_true)

        for i in self.__pins['seg']:
            GPIO.output(i, not self.__real_true) 
开发者ID:spoonysonny,项目名称:SAKS-SDK,代码行数:24,代码来源:digital_display.py

示例14: set_byte

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def set_byte(self, data):
        '''
        Set a byte
        :param data: data
        :return: void
        '''
        for i in range (0, 8):
            self.set_bit((data >> i) & 0x01)

        GPIO.output(self.__pins['clk'], not self.__real_true)
        self.bus_delay()

        GPIO.output(self.__pins['di'], self.__real_true)
        self.bus_delay()

        GPIO.output(self.__pins['clk'], self.__real_true)
        self.bus_delay() 
开发者ID:spoonysonny,项目名称:SAKS-SDK,代码行数:19,代码来源:ic_tm1637.py

示例15: toggleLED

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import output [as 别名]
def toggleLED(channel):
	global status
	if status == 0:
		status = 1
	else:
		status = 0
	
	GPIO.output(led, status) 
开发者ID:SecPi,项目名称:SecPi,代码行数:10,代码来源:gpio_test.py


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