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


Python Pin.OUT属性代码示例

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


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

示例1: playnotes

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def playnotes(self, title, length=150, duty=64):
        # Init
        p = Pin(27, Pin.OUT)
        self.pwm = PWM(p)
        self.pwm.duty(0)

        if title not in self.notes:
          print('unknown title: {}'.format(title))
          return

        melody = self.notes[title]
        print('Play', title)
        for i in melody:
            if i == 0:
                self.pwm.duty(0)
            else:
                self.pwm.freq(i)
                self.pwm.duty(duty)
            time.sleep_ms(length)

        # deinit
        self.pwm.deinit() 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:24,代码来源:buzzer.py

示例2: get_spi

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def get_spi(self): 
        spi = None
        id = 1
        
        if config_lora.IS_ESP8266:
            spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0)
            spi.init()
            
        if config_lora.IS_ESP32:
            try:
                if config_lora.SOFT_SPI: id = -1              
                spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0, bits = 8, firstbit = SPI.MSB,
                          sck = Pin(self.PIN_ID_SCK, Pin.OUT, Pin.PULL_DOWN),
                          mosi = Pin(self.PIN_ID_MOSI, Pin.OUT, Pin.PULL_UP),
                          miso = Pin(self.PIN_ID_MISO, Pin.IN, Pin.PULL_UP))
                spi.init()
                    
            except Exception as e:
                print(e)
                if spi: 
                    spi.deinit()
                    spi = None
                reset()  # in case SPI is already in use, need to reset. 
        
        return spi 
开发者ID:Wei1234c,项目名称:SX127x_driver_for_MicroPython_on_ESP8266,代码行数:27,代码来源:controller_esp.py

示例3: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self):
        self.notes = {
            'cdef': [
                self.C6, self.D6, self.E6, self.F6, self.G6, self.A6, self.B6, self.C7, self.D7, self.E7, self.F7, self.G7, self.A7, self.B7, self.C8, 0
            ],
            'mario': [
                self.E7, self.E7,  0, self.E7,  0, self.C7, self.E7,  0, self.G7,  0,  0,  0, self.G6,  0,  0,  0,
                self.C7,  0,  0, self.G6,  0,  0, self.E6,  0,  0, self.A6,  0, self.B6,  0, self.AS6, self.A6, 0,
                self.G6, self.E7,  0, self.G7, self.A7,  0, self.F7, self.G7,  0, self.E7,  0, self.C7, self.D7, self.B6,  0,  0,
                self.C7,  0,  0, self.G6,  0,  0, self.E6,  0,  0, self.A6,  0, self.B6,  0, self.AS6, self.A6, 0,
                self.G6, self.E7,  0, self.G7, self.A7,  0, self.F7, self.G7,  0, self.E7,  0, self.C7, self.D7, self.B6,  0,  0
            ],
            'starwars': [
                self.A4,  0,  0,  0, self.A4,  0,  0,  0, self.A4,  0,  0,  0, self.F4,  0,  0, self.C5,
                self.A4,  0,  0,  0, self.F4,  0,  0, self.C5, self.A4,  0,  0,  0,  0,  0,  0,  0,
                self.E5,  0,  0,  0, self.E5,  0,  0,  0, self.E5,  0,  0,  0, self.F5,  0,  0, self.C5,
                self.GS4, 0,  0,  0, self.F4,  0,  0, self.C5, self.A4,  0,  0,  0,  0,  0,  0,  0,
            ],
        }

        # Init
        self.pwm = PWM(Pin(27, Pin.OUT))
        self.pwm.duty(0) 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:25,代码来源:buzzer.py

示例4: digital_write

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def digital_write(self, payload):
        """
        Write to a digital gpio pin
        :param payload:
        :return:
        """
        pin = payload['pin']
        mode = Pin.OUT
        if 'drain' in payload:
            if not payload['drain']:
                mode = Pin.OPEN_DRAIN
        pin_object = Pin(pin, mode)
        pwm = PWM(pin_object)
        pwm.deinit()
        Pin(pin, mode, value=payload['value'])
        self.input_pin_objects[pin] = None 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:18,代码来源:esp_8266Full.py

示例5: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self, sck, mosi, miso, rst, cs):

		self.sck = Pin(sck, Pin.OUT)
		self.mosi = Pin(mosi, Pin.OUT)
		self.miso = Pin(miso)
		self.rst = Pin(rst, Pin.OUT)
		self.cs = Pin(cs, Pin.OUT)

		self.rst.value(0)
		self.cs.value(1)
		
		board = uname()[0]

		if board == 'WiPy' or board == 'LoPy' or board == 'FiPy':
			self.spi = SPI(0)
			self.spi.init(SPI.MASTER, baudrate=1000000, pins=(self.sck, self.mosi, self.miso))
		elif board == 'esp8266':
			self.spi = SPI(baudrate=100000, polarity=0, phase=0, sck=self.sck, mosi=self.mosi, miso=self.miso)
			self.spi.init()
		else:
			raise RuntimeError("Unsupported platform")

		self.rst.value(1)
		self.init() 
开发者ID:wendlers,项目名称:micropython-mfrc522,代码行数:26,代码来源:mfrc522.py

示例6: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self, gnd, sck, data, vcc):
        self.gnd = gnd
        self.sck = sck
        self.data = data
        self.vcc = vcc

        self.gnd.mode(Pin.OUT)
        self.vcc.mode(Pin.OUT)
        self.sck.mode(Pin.OUT)
        self.data.mode(Pin.OPEN_DRAIN)

        self.gnd.pull(Pin.PULL_DOWN)
        self.vcc.pull(Pin.PULL_UP)
        self.sck.pull(Pin.PULL_DOWN)
        self.data.pull(None)

        self.sleep() 
开发者ID:ayoy,项目名称:upython-aq-monitor,代码行数:19,代码来源:sht1x.py

示例7: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self, idx, is_debug=False):
        
        gpio_a, gpio_b, self.motor_install_dir = Motor.MOTOR_LIST[idx]
        # A相PWM
        self.pwm_a = PWM(
            Pin(gpio_a, Pin.OUT),
            freq = Motor.MOTOR_PWM_FREQUENCY,
            duty = 0)
        
        # B相PWM
        self.pwm_b = PWM(
            Pin(gpio_b, Pin.OUT),
            freq = Motor.MOTOR_PWM_FREQUENCY,
            duty = 0)
        
        # 电机安装方向
        if not self.motor_install_dir:
            self.pwm_a, self.pwm_b = self.pwm_b, self.pwm_a
        
        # 电机速度信号 取值范围: -1023 - 1023 
        self._pwm = 0
        # 设置电机的PWM
        # self.pwm(self._pwm) 
开发者ID:1zlab,项目名称:1ZLAB_PyEspCar,代码行数:25,代码来源:motor.py

示例8: set_dotstar_power

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def set_dotstar_power(state):
    """Set the power for the on-board Dostar to allow no current draw when not needed."""
    # Set the power pin to the inverse of state
    if state:
        Pin(DOTSTAR_PWR, Pin.OUT, None)  # Break the PULL_HOLD on the pin
        Pin(DOTSTAR_PWR).value(False)  # Set the pin to LOW to enable the Transistor
    else:
        Pin(13, Pin.IN, Pin.PULL_HOLD)  # Set PULL_HOLD on the pin to allow the 3V3 pull-up to work

    Pin(
        DOTSTAR_CLK, Pin.OUT if state else Pin.IN
    )  # If power is on, set CLK to be output, otherwise input
    Pin(
        DOTSTAR_DATA, Pin.OUT if state else Pin.IN
    )  # If power is on, set DATA to be output, otherwise input

    # A small delay to let the IO change state
    time.sleep(0.035)


# Dotstar rainbow colour wheel 
开发者ID:tinypico,项目名称:tinypico-micropython,代码行数:23,代码来源:tinypico.py

示例9: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self, reset, dc, busy, cs, clk, mosi):
        self.reset_pin = reset
        self.reset_pin.mode(Pin.OUT)

        self.dc_pin = dc
        self.dc_pin.mode(Pin.OUT)

        self.busy_pin = busy
        self.busy_pin.mode(Pin.IN)

        self.cs_pin = cs
        self.cs_pin.mode(Pin.OUT)
        self.cs_pin.pull(Pin.PULL_UP)

        self.spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))

        self.width = EPD_WIDTH
        self.height = EPD_HEIGHT
        self.rotate = ROTATE_0 
开发者ID:ayoy,项目名称:micropython-waveshare-epd,代码行数:21,代码来源:epd1in54b.py

示例10: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self, name, pin, *args, high_command='on', low_command='off',
                 ignore_case=True, on_change=None, report_change=False):
        if len(args) > 0:
            high_command = args[0]
            if len(args) > 1:
                low_command = args[1]
        if ignore_case:
            high_command = high_command.lower()
            low_command = low_command.lower()
        self.high_command = high_command
        self.low_command = low_command
        Device.__init__(self, name, pin,
                        setters={"set": self.evaluate}, ignore_case=ignore_case,
                        on_change=on_change, report_change=report_change,
                        value_map={1: self.high_command, 0: self.low_command})
        pin.init(Pin.OUT)
        self.state = pin() 
开发者ID:ulno,项目名称:ulnoiot-upy,代码行数:19,代码来源:output.py

示例11: test

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def test():
    print('Test for IR receiver. Assumes NEC protocol. Turn LED on or off.')
    if platform == 'pyboard':
        p = Pin('X3', Pin.IN)
        led = LED(2)
    elif platform == 'esp8266':
        freq(160000000)
        p = Pin(13, Pin.IN)
        led = Pin(2, Pin.OUT)
        led(1)
    elif ESP32:
        p = Pin(23, Pin.IN)
        led = Pin(21, Pin.OUT)  # LED with 220Ω series resistor between 3.3V and pin 21
        led(1)
    ir = NEC_IR(p, cb, True, led)  # Assume extended address mode r/c
    loop = asyncio.get_event_loop()
    loop.run_forever() 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:19,代码来源:art1.py

示例12: test

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def test():
    print('Test for IR receiver. Assumes NEC protocol. Turn LED on or off.')
    if platform == 'pyboard':
        p = Pin('X3', Pin.IN)
        led = LED(2)
    elif platform == 'esp8266':
        freq(160000000)
        p = Pin(13, Pin.IN)
        led = Pin(2, Pin.OUT)
        led(1)
    elif ESP32:
        p = Pin(23, Pin.IN)
        led = Pin(21, Pin.OUT)  # LED with 220Ω series resistor between 3.3V and pin 21
        led(1)
    ir = NEC_IR(p, cb, True, led)  # Assume extended address mode r/c
    loop = asyncio.get_event_loop()
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        print('Interrupted')
    finally:
        asyncio.new_event_loop()  # Still need ctrl-d because of interrupt vector 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:24,代码来源:art1.py

示例13: heartbeat

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def heartbeat(tms):
    if platform == 'pyboard':  # V1.x or D series
        from pyb import LED
        led = LED(1)
    elif platform == 'esp8266':
        from machine import Pin
        led = Pin(2, Pin.OUT, value=1)
    elif platform == 'linux':
        return  # No LED
    else:
        raise OSError('Unsupported platform.')
    while True:
        if platform == 'pyboard':
            led.toggle()
        elif platform == 'esp8266':
            led(not led())
        await asyncio.sleep_ms(tms) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:19,代码来源:heartbeat.py

示例14: test

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def test():
    freq(160000000)
    dout = Pin(14, Pin.OUT, value = 0)     # Define pins
    ckout = Pin(15, Pin.OUT, value = 0)    # clocks must be initialised to zero.
    din = Pin(13, Pin.IN)
    ckin = Pin(12, Pin.IN)

    channel = SynCom(True, ckin, ckout, din, dout)
    loop = asyncio.get_event_loop()
    loop.create_task(heartbeat())
    loop.create_task(channel.start(passive_task))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass
    finally:
        ckout(0) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:19,代码来源:sr_passive.py

示例15: __init__

# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import OUT [as 别名]
def __init__(self, trigger_pin, echo_pin, echo_timeout_us=500*2*30):
        """
        trigger_pin: Output pin to send pulses
        echo_pin: Readonly pin to measure the distance. The pin should be protected with 1k resistor
        echo_timeout_us: Timeout in microseconds to listen to echo pin.
        By default is based in sensor limit range (4m)
        """
        self.echo_timeout_us = echo_timeout_us
        # Init trigger pin (out)
        self.trigger = Pin(trigger_pin, mode=Pin.OUT)
        self.trigger.value(0)
        # Init echo pin (in)
        if (uname().sysname == 'WiPy'):
            self.echo = Pin(echo_pin, mode=Pin.OPEN_DRAIN)
        else:
            self.echo = Pin(echo_pin, mode=Pin.IN) 
开发者ID:lemariva,项目名称:uPySensors,代码行数:18,代码来源:hcsr04.py


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