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

Python wiringpi.pinMode函数代码示例

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

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



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

示例1: configureHardware

def configureHardware(postMotionEvent, postButtonClickEvent):
    wiringpi.wiringPiSetupGpio()

    # PIR motion detector
    def reportMotion():
        if wiringpi.digitalRead(BCM_PIR) == 1:
            postMotionEvent()

    wiringpi.pinMode(BCM_PIR, wiringpi.GPIO.INPUT)
    wiringpi.pullUpDnControl(BCM_PIR, wiringpi.GPIO.PUD_OFF)
    wiringpi.wiringPiISR(BCM_PIR, wiringpi.GPIO.INT_EDGE_BOTH, reportMotion)

    # Display buttons
    for btnNum, bcmPin in (
                (1, BCM_BTN_1),
                (2, BCM_BTN_2),
                (3, BCM_BTN_3),
            ):
        @debounce(0.02)
        def reportClick(_bcmPin=bcmPin, _btnNum=btnNum):
            if wiringpi.digitalRead(_bcmPin) == 0:
                postButtonClickEvent(_btnNum)

        wiringpi.pinMode(bcmPin, wiringpi.GPIO.INPUT)
        wiringpi.pullUpDnControl(bcmPin, wiringpi.GPIO.PUD_UP)
        wiringpi.wiringPiISR(bcmPin, wiringpi.GPIO.INT_EDGE_BOTH, reportClick)

    # Servos
    wiringpi.pinMode(BCM_SERVO_ACTIVATION, wiringpi.GPIO.OUTPUT)
    wiringpi.pinMode(BCM_SERVO_SPRING, wiringpi.GPIO.OUTPUT)
    wiringpi.pinMode(BCM_SERVO_HOLDER, wiringpi.GPIO.OUTPUT)
开发者ID:stefanomasini,项目名称:hi5,代码行数:31,代码来源:hardware.py


示例2: 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


示例3: _switch

    def _switch(self, switch):
        self.bit = [142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 136, 128, 0, 0, 0]

        for t in range(5):
            if self.system_code[t]:
                self.bit[t] = 136
        x = 1
        for i in range(1, 6):
            if self.unit_code & x > 0:
                self.bit[4 + i] = 136
            x = x << 1

        if switch == wiringpi.HIGH:
            self.bit[10] = 136
            self.bit[11] = 142

        bangs = []
        for y in range(16):
            x = 128
            for i in range(1, 9):
                b = (self.bit[y] & x > 0) and wiringpi.HIGH or wiringpi.LOW
                bangs.append(b)
                x = x >> 1

        wiringpi.wiringPiSetupSys()
        wiringpi.pinMode(self.pin, wiringpi.OUTPUT)
        wiringpi.digitalWrite(self.pin, wiringpi.LOW)
        for z in range(self.repeat):
            for b in bangs:
                wiringpi.digitalWrite(self.pin, b)
                time.sleep(self.pulselength / 1000000.0)
开发者ID:Brootux,项目名称:rc_switch_server.py,代码行数:31,代码来源:LibRemoteSwitch.py


示例4: main

def main():
    delay = 1E-2 # seconds

    # set up pins
    wiringpi.wiringPiSetup()
    for pin in pinsA:
        wiringpi.pinMode( pin, 1 )
    for pin in pinsB:
        wiringpi.pinMode( pin, 1 )
    for pin in pinsOut:
        wiringpi.pinMode( pin, 0 )
    wiringpi.pinMode( isSignedPin, 1 )
    wiringpi.pinMode( isSupportedPin, 0 )
    
    numFails = testUnsigned(delay)
    numFails += testSigned(delay)

    # magic for coloured printing from https://pythonadventures.wordpress.com/2011/03/16/print-colored-text-in-terminal/
    colorred = "\033[01;31m{0}\033[00m"
    colorgrn = "\033[1;36m{0}\033[00m"
    
    if numFails > 0:
        print colorred.format("%d tests were failed" % numFails)
    else:
        print colorgrn.format("All tests passed")
开发者ID:horjecazador,项目名称:D2,代码行数:25,代码来源:autotest.py


示例5: __init__

    def __init__(self, dev=(0,0),speed=5000000, brightness=256, contrast=CONTRAST):
        self.spi = spidev.SpiDev()
        self.speed = speed
        self.dev = dev
        self.spi.open(self.dev[0],self.dev[1])
        self.spi.max_speed_hz=self.speed

        # Set pin directions.
        self.dc = DC
        self.rst = RST
        wiringpi.wiringPiSetup()
        for pin in [self.dc, self.rst]:
          # pin=self.dc
          wiringpi.pinMode(pin, 1)

        self.contrast=contrast
        self.brightness=brightness
        
        # Toggle RST low to reset.
        wiringpi.digitalWrite(self.rst, OFF)
        time.sleep(0.100)
        wiringpi.digitalWrite(self.rst, ON)
        # Extended mode, bias, vop, basic mode, non-inverted display.
        wiringpi.digitalWrite(self.dc, OFF)
        self.spi.writebytes([0x21, 0x14, self.contrast, 0x20, 0x0c])
开发者ID:calexo,项目名称:CaMuMa,代码行数:25,代码来源:nokiaSPI.py


示例6: fan

	def fan(self, status, waitTime=0):
		time.sleep(waitTime)

		if status:
			wiringpi.pinMode(PIN_FAN, ON)
		else:
			wiringpi.pinMode(PIN_FAN, OFF)
开发者ID:rbioque,项目名称:inKoutPi,代码行数:7,代码来源:rele.py


示例7: __init__

    def __init__(self):
        threading.Thread.__init__(self)
        self.watchdog = Watchdog()
        self.watchdog.daemon = True
        self.watchdog.start()
        time.sleep(1)

        self.setup = settings.setup
        self.quit = False
        for i in range(0, 7): #Set GPIO pins to output
            wp.pinMode(i, 1)
        self.setup = settings.setup
        self.dutycycles = [0, 0, 0, 0, 0, 0]

        channels = ['1', '2', '3', '4', '5', '6']
        # Setup up extra status for the diode relay status
        diode_channels = ['diode' + number for number in channels]
        self.diode_channel_last = {name: None for name in diode_channels}

        # Setup sockets
        self.livesocket = LiveSocket(self.setup + '-bakeout', channels + diode_channels)
        self.livesocket.start()
        self.pullsocket = DateDataPullSocket(self.setup + '-bakeout', channels, timeouts=None)
        self.pullsocket.start()
        self.pushsocket = DataPushSocket(self.setup + '-push_control', action='enqueue')
        self.pushsocket.start()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:26,代码来源:bakeout.py


示例8: main

def main():
    #all needs to run automatically
    port0 = '/dev/ttyUSB0'
    port1 = '/dev/ttyUSB1'
    port2 = '/dev/ttyUSB2'
    ##
    th_cl1 = TestThread(port1, './original_data/data1208.csv')
    th_cl1 = TestThread(port1, './original_data/data1208.csv')

    #th_cl1.start()
    #th_cl2.start()

    f = open('./original_data/data1209.csv', 'w')
    ##
    servo_pin = 18

    param = sys.argv
    set_degree = int(param[1])
    print(set_degree)

    wiringpi.wiringPiSetupGpio()

    wiringpi.pinMode(servo_pin, 2)

    wiringpi.pwmSetMode(0)
    wiringpi.pwmSetRange(1024)
    wiringpi.pwmSetClock(375)


    while True:
        try:
            ser = serial.Serial(port0, 38400, timeout=10)  # 10s-timeout baudrate=38400
            ser.write(b'<RM,>??\r\n')  # send command (CR+LF)
            line = ser.readline()
            line = str(datetime.datetime.now()) + str(",") + line.decode('utf-8')
            line = line.split(',')

            velocity = float(line[2])
            temp = float(line[5])

            print('CPU_temperature' + '/' + line[0] + ',' + line[2] + ','
                    + line[3] + ',' + line[4] + ',' + line[5])
            f.write(line[0] + ',' + line[2] + ','
                    + line[3] + ',' + line[4] + ',' + line[5] + "\n")

            if temp >= 35.0:
#                print('too hot')
                wiringpi.pwmWrite(servo_pin, set_degree + 5)
#                LED(11, True)
            else:
#                print('oh.. cool')
#                move_deg = int (81+41/90*set_degree)

                wiringpi.pwmWrite(servo_pin, set_degree)
#                LED(11, False)

            time.sleep(5)

        except IndexError:
            pass
开发者ID:noguchi0123,项目名称:sensor,代码行数:60,代码来源:get_data.py


示例9: __init__

	def __init__(self, pin, name, pwmCountUpFrequency, pwmCycleRange):
		# このservoが接続されるGPIO番号
		# GPIO12またはGPIO18のみサポートされる(GPIO12と13は同じ内容、GPIO18と19は同じ内容となる)
		self.pin = pin
		self.name = name
		self.pwmCountUpFrequency = pwmCountUpFrequency
		self.pwmCycleRange = pwmCycleRange

		# ピン設定
		wiringpi.pinMode(pin, wiringpi.PWM_OUTPUT)

		# see: http://qiita.com/locatw/items/f15fd9df40153bbb4d27
		# PWMのカウンタ周期:19.2[MHz]/clock=19.2∗10^6/400=48[KHz]≒0.0208[ms]
		self.pwmFrequency = float(SG90Direct.PRI_PWM_BASE_CLOCK_FREQUENCY / self.pwmCountUpFrequency)
		# PWM周波数:19.2[MHz]/clock/range=19.2∗106/400/1024=46.875[Hz]≒21.3[ms]
		self.pwmCycleSec = 1.0 / self.pwmFrequency * self.pwmCycleRange
		# 48[KHz]∗0.5[ms]=48000[Hz]∗0.0005[s]=24
		self.minPmwValue = int(self.pwmFrequency * SG90Direct.MIN_ANGLE_SEC)
		# 48[KHz]∗2.4[ms]=48000[Hz]∗0.0024[s]=115.2≒115
		self.maxPmwValue = int(self.pwmFrequency * SG90Direct.MAX_ANGLE_SEC)
		self.deltaPmwValue = self.maxPmwValue - self.minPmwValue

		print 'pin: ' + str(self.pin) + ', pwmCountUpFrequency: ' + str(self.pwmCountUpFrequency) + 'Hz, pwmCycleRange: ' + str(self.pwmCycleRange)
		print 'pwmFrequency: ' + ('%.3f' % self.pwmFrequency) + ' Hz(' + ('%.6f' % (1.0 / self.pwmFrequency)) + ' sec), pwmCycleSec: ' + ('%.6f' % self.pwmCycleSec)
		print 'reference pwmCycleSec: ' + str(SG90Direct.REFERENCE_PWM_1CYCLE_SEC)
		print 'minPmwValue: ' + str(self.minPmwValue) + ', maxPmwValue: ' + str(self.maxPmwValue) + ', deltaPmwValue: ' + str(self.deltaPmwValue)
开发者ID:maimuzo,项目名称:mearm-ps3controller-for-raspberrypi,代码行数:26,代码来源:rpi_direct_servo_controller.py


示例10: main

def main():
    if wp.wiringPiSetup() == -1:
        print ("Unable to start wiringPi")
        sys.exit(1)

    if wp.wiringPiSPISetup(SPI_CHANNEL, SPI_SPEED) == -1:
        print ("wiringPiSPISetup Failed")
        sys.exit(1)

    wp.pinMode(CS_MCP3208, wp.OUTPUT)

    while 1:
        t = time.time()

        vt = read_adc(0)
        R = (10000*vt)/(5-vt)
        vt = 5*R/(R+10000)
        temp = -0.3167*(vt**6) + 4.5437*(vt**5) - 24.916*(vt**4) + 63.398*(vt**3) - 67.737*vt*vt - 13.24*vt + 98.432

        vh = read_adc(1)
        humidity = (((vh/5.0)-0.16)/0.0062)/(1.0546-0.00216*temp)

        print('{} Temp={}C, Humid={}%'.format(t, temp, humidity))
        data = 'rasptest temp={},hum={} {:d}'.format(temp, humidity, int(t * (10**9)))
        print("Send data to DB")
        r = requests.post('http://192.168.1.231:8086/write', auth=('mydb', 'O7Bf3CkiaK6Ou8eqYttU'), params={'db': 'mydb'}, data=data)
        print("Return status: {}", r.status_code)

        time.sleep(30)
开发者ID:pige252,项目名称:python,代码行数:29,代码来源:simple.py


示例11: 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


示例12: __init__

 def __init__(self, config):
     import wiringpi
     Unlocker.__init__(self, config)
     # PIN numbers follow P1 header BCM GPIO numbering, see https://projects.drogon.net/raspberry-pi/wiringpi/pins/
     # Local copy of the P1 in repo mapping see gpio_vs_wiringpi_numbering_scheme.png.
     wiringpi.wiringPiSetupGpio()
     self.lockPin = self.config.getint("UnlockerWiringPi", "lock_pin")
     wiringpi.pinMode(self.lockPin, wiringpi.OUTPUT) #output
开发者ID:hiviah,项目名称:brmdoor_libnfc,代码行数:8,代码来源:unlocker.py


示例13: ensure_button_setup

def ensure_button_setup():
    import wiringpi

    ensure_wiringpi_setup()

    for button_pin in button_pins:
        wiringpi.pinMode(button_pin, wiringpi.INPUT)
        wiringpi.wiringPiISR(button_pin, wiringpi.INT_EDGE_BOTH, GPIO_callback)
开发者ID:furbrain,项目名称:tingbot-python,代码行数:8,代码来源:tingbot.py


示例14: triggerRemote

def triggerRemote():
  if PI_SETUP:
    wiringpi.pinMode(CAMERA_PIN, 1)
    wiringpi.digitalWrite(CAMERA_PIN, 1)
    utilities.wait(0.1)
    wiringpi.digitalWrite(CAMERA_PIN, 0)
  else:
    print "Can't trigger remote, not pi"
开发者ID:stevenacalhoun,项目名称:comp-photo-project,代码行数:8,代码来源:cameraControl.py


示例15: __init__

    def __init__(self):

        wiringpi.wiringPiSetupGpio()
        wiringpi.pinMode(self.PIN_PWM, wiringpi.GPIO.PWM_OUTPUT)
        wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
        wiringpi.pwmSetClock(375)

        wiringpi.pwmWrite(self.PIN_PWM, self.FRONT)
开发者ID:emetriath,项目名称:raspi,代码行数:8,代码来源:cannon.py


示例16: __preRead

	def __preRead(self):
		# (1) set all columns as output low
		for j in range(len(self.col)):
			wiringpi.pinMode(self.col[j],OUTPUT)
			wiringpi.digitalWrite(self.col[j],LOW)

		# (2) set all rows as input
		for i in range(len(self.row)):
			wiringpi.pinMode(self.row[i],INPUT)
开发者ID:bandono,项目名称:matrixQPi,代码行数:9,代码来源:matrixQPi.py


示例17: __init__

    def __init__(self, pt, pe):
        threading.Thread.__init__(self)
        Observable.__init__(self)
        self.pinTrigger = pt
        self.pinEcho = pe

        if not Globals.globSimulate:
	    wiringpi.pinMode(self.pinTrigger, GPIO_OUTPUT)
	    wiringpi.pinMode(self.pinEcho, GPIO_INPUT)
开发者ID:StevenVanAcker,项目名称:ProjectHelios,代码行数:9,代码来源:DistanceSensor.py


示例18: __init__

 def __init__(self, power_calculator, datasocket):
     threading.Thread.__init__(self)
     self.pinnumber = 0
     self.pc = power_calculator
     self.datasocket = datasocket
     self.beatperiod = 5 # seconds
     self.beatsteps = 100
     self.dutycycle = 0
     self.quit = False
     wp.pinMode(self.pinnumber, 1)  # Set pin 0 to output
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:10,代码来源:temperature_controller.py


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python wiringpi.pwmWrite函数代码示例发布时间:2022-05-26
下一篇:
Python wiringpi.digitalWrite函数代码示例发布时间: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