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


Python pyb.DAC属性代码示例

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


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

示例1: pins_test

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import DAC [as 别名]
def pins_test():
    i2c = I2C(1, I2C.MASTER)
    spi = SPI(2, SPI.MASTER)
    uart = UART(3, 9600)
    servo = Servo(1)
    adc = ADC(Pin.board.X3)
    dac = DAC(1)
    pin = Pin('X4', mode=Pin.AF_PP, af=Pin.AF3_TIM9)
    pin = Pin('Y1', mode=Pin.AF_OD, af=3)
    pin = Pin('Y2', mode=Pin.OUT_PP)
    pin = Pin('Y3', mode=Pin.OUT_OD, pull=Pin.PULL_UP)
    pin.high()
    pin = Pin('Y4', mode=Pin.OUT_OD, pull=Pin.PULL_DOWN)
    pin.high()
    pin = Pin('X18', mode=Pin.IN, pull=Pin.PULL_NONE)
    pin = Pin('X19', mode=Pin.IN, pull=Pin.PULL_UP)
    pin = Pin('X20', mode=Pin.IN, pull=Pin.PULL_DOWN)
    print('===== output of pins() =====')
    pins.pins()
    print('===== output of af() =====')
    pins.af() 
开发者ID:dhylands,项目名称:upy-examples,代码行数:23,代码来源:af_test.py

示例2: pins_test

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import DAC [as 别名]
def pins_test():
    i2c = I2C(1, I2C.MASTER)
    spi = SPI(2, SPI.MASTER)
    uart = UART(3, 9600)
    servo = Servo(1)
    adc = ADC(Pin.board.X3)
    dac = DAC(1)
    pin = Pin('X4', mode=Pin.AF_PP, af=Pin.AF3_TIM9)
    pin = Pin('Y1', mode=Pin.AF_OD, af=3)
    pin = Pin('Y2', mode=Pin.OUT_PP)
    pin = Pin('Y3', mode=Pin.OUT_OD, pull=Pin.PULL_UP)
    pin.high()
    pin = Pin('Y4', mode=Pin.OUT_OD, pull=Pin.PULL_DOWN)
    pin.high()
    pin = Pin('X18', mode=Pin.IN, pull=Pin.PULL_NONE)
    pin = Pin('X19', mode=Pin.IN, pull=Pin.PULL_UP)
    pin = Pin('X20', mode=Pin.IN, pull=Pin.PULL_DOWN)
    print('===== output of pins() =====')
    pins()
    print('===== output of af() =====')
    af() 
开发者ID:dhylands,项目名称:upy-examples,代码行数:23,代码来源:pin_dump.py

示例3: sine_sweep

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import DAC [as 别名]
def sine_sweep(start, end, mult):     # Emit sinewave on DAC1
    buf = bytearray(100)
    for i in range(len(buf)):
        buf[i] = 128 + int(110 * math.sin(2 * math.pi * i / len(buf)))

    freq = start
    while True:
        dac1.write_timed(buf, int(freq) * len(buf), mode=pyb.DAC.CIRCULAR)
        print(freq, "Hz")
        pyb.delay(2500)
        freq *= mult
        if freq > end:
            freq = start 
开发者ID:peterhinch,项目名称:micropython-filters,代码行数:15,代码来源:osc.py

示例4: signal

# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import DAC [as 别名]
def signal():  # Could use write_timed but this prints values
    dac = pyb.DAC(1, bits=12, buffering=True)
    v = 0
    while True:
        if not v & 0xf:
            print('write', v << 4)  # Make value u16 as per ADC read
        dac.write(v)
        v += 1
        v %= 4096
        await asyncio.sleep_ms(50) 
开发者ID:peterhinch,项目名称:micropython-async,代码行数:12,代码来源:adctest.py


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