• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wiringpi.digitalRead函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wiringpi.digitalRead函数的典型用法代码示例。如果您正苦于以下问题:Python digitalRead函数的具体用法?Python digitalRead怎么用?Python digitalRead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: pinBlinkInterval

def pinBlinkInterval(pin, Timeout):
    # initialisation compteur
    startTime = getStartTime()
    
    initPinState = GPIO.digitalRead(pin)
    startCounting=False
    firstPulse = False
    pulse = 0
    ## récupération d'un cycle
    while True :
        # gestion du timeout
        if ( isTimeoutExpired(startTime, Timeout) ):
            return -1
            
        #time.sleep(0.01)
        # lecture de la pin
        if (startCounting == False ):
            if (GPIO.digitalRead(pin) != initPinState):
                startCounting = True
                pulse = getStartTime()
        else:
            if (firstPulse == False):
                if (GPIO.digitalRead(pin) == initPinState):
                    firstPulse = True
            if (firstPulse and GPIO.digitalRead(pin) != initPinState):
                return getStartTime() - pulse
开发者ID:y0gi44,项目名称:SenseoPi,代码行数:26,代码来源:senseo.py


示例2: poll

def poll():
	if wiringpi.digitalRead(WIN):
		print 'win'
	elif wiringpi.digitalRead(LOSE):
		print 'lose'
	else:
		print 'playing'
开发者ID:timpressive,项目名称:project-omega,代码行数:7,代码来源:controls.py


示例3: pulse_in

def pulse_in(gpio, state, timeout):
    tn = datetime.datetime.now()
    t0 = datetime.datetime.now()
    micros = 0

    while wp.digitalRead(gpio) != state:
        tn = datetime.datetime.now()
        if tn.second > t0.second:
            micros = 1000000L
        else:
            micros = 0
        micros += tn.microsecond - t0.microsecond
        if micros > timeout:
            return 0

    t1 = datetime.datetime.now()

    while wp.digitalRead(gpio) == state:
        tn = datetime.datetime.now()
        if tn.second > t0.second:
            micros = 1000000L
        else:
            micros = 0
        micros = micros + (tn.microsecond - t0.microsecond)
        if micros > timeout:
            return 0

    if tn.second > t1.second:
        micros = 1000000L
    else:
        micros = 0
    micros = micros + (tn.microsecond - t1.microsecond)

    return micros
开发者ID:djamelz,项目名称:HomeEasyPiPy,代码行数:34,代码来源:ReceiverPiPy.py


示例4: scanQ

	def scanQ(self):
		# steps (1) and (2) before reading GPIOs
		self.__preRead()
		
		# (3) scan rows for pushed key/button
		rowHi=1
		while rowHi==1:
			for i in range(len(self.row)):
				tmpRead=wiringpi.digitalRead(self.row[i])
				if tmpRead==0:
					rowHi=0
					rowVal=i

		# (4) after finding which key/button from the row scans, convert columns to input
		for j in range(len(self.col)):
				wiringpi.pinMode(self.col[j],INPUT)

		# (5) switch the i-th row found from scan to output
		wiringpi.pinMode(self.row[rowVal],OUTPUT)
		wiringpi.digitalWrite(self.row[rowVal],HIGH)

		# (6) scan columns for still-pushed key/button
		colLo=0
		while colLo==0:
				for j in range(len(self.col)):
						tmpRead=wiringpi.digitalRead(self.col[j])
						if tmpRead==1:
							colLo=1
							colVal=j

		# reinitialize used GPIOs
		self.__postRead()

		# (7) return the symbol of pressed key from keyPad mapping
		return self.keyPad[rowVal][colVal]
开发者ID:bandono,项目名称:matrixQPi,代码行数:35,代码来源:matrixQPi.py


示例5: updateValue

    def updateValue(self):
	if Globals.globSimulate:
	    val = (self.values[-1][1] if len(self.values) > 0 else 0) + random.randint(-10, 10)
	else:
	    # Send 10us pulse to trigger
	    wiringpi.digitalWrite(self.pinTrigger, 1)
	    time.sleep(0.00001)
	    wiringpi.digitalWrite(self.pinTrigger, 0)
	    start = time.time()
	    stop = 0

	    while wiringpi.digitalRead(self.pinEcho)==0:
	      start = time.time()

	    while wiringpi.digitalRead(self.pinEcho)==1:
	      stop = time.time()

	    # Calculate pulse length
	    elapsed = stop-start

	    # Distance pulse travelled in that time is time
	    # multiplied by the speed of sound (cm/s)
	    distance = elapsed * 34300

	    # That was the distance there and back so halve the value
	    val = distance / 2


	if val < 0:
	    val = 0

	currtime = int(time.time() * 1000) # this is milliseconds so JavaScript doesn't have to do this
	self.values.append([currtime, val])
	self.values = self.values[-MAXVALUES:]
	self.emit("DistanceSensor", self)
开发者ID:StevenVanAcker,项目名称:ProjectHelios,代码行数:35,代码来源:DistanceSensor.py


示例6: hot_wire

def hot_wire(enable):
    if enable:
        logging.info('Heating wire enabled Temp={0:0.1f}* < Temp_min={1:0.1f}'.format(temperature, TEMP_MIN))
	wiringpi.pinMode(PIN_WIRE, ON)
	logging.debug(wiringpi.digitalRead(PIN_WIRE))
    else:
        logging.info('Heating wire disabled Temp={0:0.1f}* > Temp_max={1:0.1f}'.format(temperature, TEMP_MAX))
	wiringpi.pinMode(PIN_WIRE, OFF)
	logging.debug(wiringpi.digitalRead(PIN_WIRE))
    return;
开发者ID:rbioque,项目名称:inKoutPi,代码行数:10,代码来源:initOld.py


示例7: fan

def fan(enable):
    if enable:
        logging.info('fan enabled')
	wiringpi.pinMode(PIN_FAN, ON)
	logging.debug(wiringpi.digitalRead(PIN_FAN))
	time.sleep(240)
	logging.info('fan disabled')
	wiringpi.pinMode(PIN_FAN, OFF)
	logging.debug(wiringpi.digitalRead(PIN_FAN))
    else:
	logging.info('fan disabled')
	wiringpi.pinMode(PIN_FAN, OFF)
	logging.debug(wiringpi.digitalRead(PIN_FAN))
    return;
开发者ID:rbioque,项目名称:inKoutPi,代码行数:14,代码来源:initOld.py


示例8: getButtonStatus

	def getButtonStatus(self):
		ret = self.BUTTON_NONE
		if self.isRun:
			# excute, if run
			val = wiringpi.digitalRead(self.pinButton)
			ret = self.BUTTON_ON if val == wiringpi.HIGH else self.BUTTON_OFF
		return ret		
开发者ID:FabLabKannai,项目名称:SumobotJr,代码行数:7,代码来源:sumobot_wii_remote_check.py


示例9: read_switch

    def read_switch(self, switch):
        if not WIRING_PI:
            return False

        pin = self.switch_pin[switch]

        return wiringpi.digitalRead(pin) > 0
开发者ID:deckerego,项目名称:GarageSecurity,代码行数:7,代码来源:piwiring.py


示例10: read_adc

def read_adc(adcnum, sCon):

    if ((adcnum > 7) or (adcnum < 0)):
        return -1
    wiringpi.digitalWrite(sCon.cspin, 1)
    wiringpi.digitalWrite(sCon.clkpin, 0)  # start clock low
    wiringpi.digitalWrite(sCon.cspin, 0)     # bring CS low

    commandout = adcnum
    commandout |= 0x18  # start bit + single-ended bit
    commandout <<= 3    # we only need to send 5 bits here
    for i in range(5):
        if (commandout & 0x80):
            wiringpi.digitalWrite(sCon.mosipin, 1)
        else:
            wiringpi.digitalWrite(sCon.mosipin, 0)
        commandout <<= 1
        wiringpi.digitalWrite(sCon.clkpin, 1)
        wiringpi.digitalWrite(sCon.clkpin, 0)

    adcout = 0
    # read in one empty bit, one null bit and 10 ADC bits
    for i in range(12):
        wiringpi.digitalWrite(sCon.clkpin, 1)
        wiringpi.digitalWrite(sCon.clkpin, 0)
        adcout <<= 1
        if (wiringpi.digitalRead(sCon.misopin)):
            adcout |= 0x1
    wiringpi.digitalWrite(sCon.cspin, 1)

    adcout >>= 1       # first bit is 'null' so drop it
    return adcout
开发者ID:Penguin2600,项目名称:projectG,代码行数:32,代码来源:sensorGetAll.py


示例11: WaitForCTS

def WaitForCTS():
    # continually monitor the selected GPIO pin and wait for the line to go low
    # print ("Waiting for CTS")     # Added for debug purposes
    while wiringpi2.digitalRead(GPIO_PIN):
        # do nothing
        time.sleep(0.001)
    return
开发者ID:BostinTechnology,项目名称:RFID_125kHz,代码行数:7,代码来源:RFIDReader.py


示例12: run

    def run(self):
        motionFirstDetectedTime = None
        SLEEP_TIME = 0.5

        # Set up the GPIO input for motion detection
        PIR_PIN = 18
        wiringpi.wiringPiSetupSys()
        wiringpi.pinMode(PIR_PIN, wiringpi.INPUT)

        # Loop through and detect motion
        while True:
            if wiringpi.digitalRead(PIR_PIN):
                if motionFirstDetectedTime is None:
                    motionFirstDetectedTime = datetime.now()
                    print('Motion detected at: ' + str(motionFirstDetectedTime))

            # Do we need to send out a notification?
            now = datetime.now()
            if (motionFirstDetectedTime is not None) and (now - motionFirstDetectedTime) > timedelta (minutes = 1):
                print('Sending out notification now!')
                motiondate = datetime.strftime(motionFirstDetectedTime, '%Y-%m-%d %H:%M:%S')
                msg = self.message + ': ' + motiondate 
                self._send_email(msg)

                # reset state
                motionFirstDetectedTime = None

            time.sleep(SLEEP_TIME)
开发者ID:pye2k,项目名称:rpi_gpio,代码行数:28,代码来源:pir_motion_detection.py


示例13: garage_state

def garage_state():
    doorState = wiringpi.digitalRead(25)
    if doorState == 1: 
		return "open"
    elif doorState == 0:
		return "closed"
    else:
		return "error"
开发者ID:jegsmith,项目名称:Web-Door-Opener-Client,代码行数:8,代码来源:tornadowsc.py


示例14: run

 def run(self):
     while not self.quit:
         time.sleep(1)
         print('!')
         if self.alarm_mode:
             movement = wp.digitalRead(0) != 0
             if movement:
                 self.turn_all_on_off(True, notify=True)
开发者ID:robertjensen,项目名称:HueApp,代码行数:8,代码来源:hue.py


示例15: __init__

  def __init__(self, pinNumber):
    threading.Thread.__init__(self)

    self.daemon = True
    self.pinNumber = pinNumber

    WiringPiSingleton().setup()

    self.__initialState = wiringpi.digitalRead(self.pinNumber)
    self.__previousState = self.__initialState
开发者ID:deckerego,项目名称:hack-clock,代码行数:10,代码来源:Input.py


示例16: is_enabled

    def is_enabled(self, button):
        if not WIRING_PI:
            return False

        pin = self.button_pin[button]

        wiringpi.pinMode(pin, 1)
        state = wiringpi.digitalRead(pin)

        return state == 1
开发者ID:deckerego,项目名称:SprinklerSwitch,代码行数:10,代码来源:piwiring.py


示例17: run

  def run(self):
    self.__running = True

    while self.__running:
      state = wiringpi.digitalRead(self.pinNumber)
      if state != self.__previousState:
        self.onStateChange(state)

      self.__previousState = state
      time.sleep(self.__RESOLUTION / 1000.0)
开发者ID:deckerego,项目名称:hack-clock,代码行数:10,代码来源:Input.py


示例18: main

def main():

	receiver = 27; sender = 1; state = 1; i = 0
	global last_high, ones, zeros, bits_to_output, code

	while True:
		wiringpi.delayMicroseconds(25)

		if wiringpi.digitalRead(receiver) == False:

			if (bits_to_output > 0):
				sys.stdout.write("0")
			zeros += 1
			
			if state < 80:
				state += 1
		else:
			if state >= 2 and bits_to_output > 0:
				bits_to_output -= 1
				#sys.stdout.write("\n")
				#sys.stdout.write(str(format(ones / (ones + zeros), '.2f')) + " ")
				#sys.stdout.write(str( (ones + zeros)) + " ")
				
				if ones / (ones + zeros) < 0.5:
					#sys.stdout.write("0")
					code += "0"
				else:
					#sys.stdout.write("1")
					code += "1"

				if bits_to_output == 0:
					sys.stdout.write("   " + code)
					sys.stdout.write("   " + compress_string(code))
				
				#sys.stdout.write(" --\n")
				ones = 0
				zeros = 0

			if state == 80:
				calc_time()
			
			if (bits_to_output > 0):
				sys.stdout.write("1")
			ones += 1
			

			if state >= 2:
				last_high = wiringpi.micros()

			state = 0

		i += 1
		if i == 40:
			sys.stdout.flush()
			i = 0
开发者ID:membrane,项目名称:iot-remote-control,代码行数:55,代码来源:receiver.py


示例19: pinIs

def pinIs(pin, statusNotWanted, nbSec):
    # initialisation compteur
    i = 0
    while True :
        time.sleep(0.1)
        # lecture de la pin
        if (GPIO.digitalRead(pin) == statusNotWanted):
            return False
        i = i+1
        if (i > nbSec*10):
            return True 
开发者ID:y0gi44,项目名称:SenseoPi,代码行数:11,代码来源:senseo.py


示例20: checkPedal

 def checkPedal(self, dt):
   try:
     # Only trigger a capture when the circuit goes from open to closed
     nextPedal = wiringpi.digitalRead(21)
     #print('checkPedal', nextPedal)
     if self.lastPedal == 1 and nextPedal == 0 and 'beginCapture' in dir(self.manager.current_screen):
       self.manager.current_screen.beginCapture()
     self.lastPedal = nextPedal
   except Exception as e:
     handleCrash(e)
   return True
开发者ID:Tenrec-Builders,项目名称:pi-scan,代码行数:11,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python wiringpi.digitalWrite函数代码示例发布时间:2022-05-26
下一篇:
Python wiredtiger.wiredtiger_open函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap