當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。