本文整理汇总了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()
示例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()
示例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
示例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)