完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
基本用法import pyb
adc = pyb.ADC(Pin('Y11')) # create an analog object from a pin adc = pyb.ADC(pyb.Pin.board.Y11) val = adc.read() # read an analog value adc = pyb.ADCAll(resolution) # creale an ADCAll object val = adc.read_channel(channel) # read the given channel val = adc.read_core_temp() # read MCU temperature val = adc.read_core_vbat() # read MCU VBAT val = adc.read_core_vref() # read MCU VREF pyb.ADC(pin)通过GPIO定义一个ADC pyb.ADCAll(resolution)定义ADC的分辨率,可以设置为8/10/12 adc.read() 读取adc的值,返回值与adc分辨率有关,8位最大255,10位最大1023,12位最大4095adc.read_channel(channel) 读取指定adc通道的值adc.read_core_temp() 读取内部温度传感器adc.read_core_vbat() 读取vbat电压 vback = adc.read_core_vbat() * 1.21 / adc.read_core_vref()adc.read_core_vref() 读取vref电压(1.21V参考) 3V3 = 3.3 * 1.21 / adc.read_core_vref()adc.read_timed(buf, timer) 以指定频率读取adc参数到buf buf,缓冲区 timer,频率(Hz)使用这个函数会将ADC的结果限制到8位 adc = pyb.ADC(pyb.Pin.board.X19) # create an ADC on pin X19 buf = bytearray(100) # create a buffer of 100 bytes adc.read_timed(buf, 10) # read analog values into buf at 10Hz #this will take 10 seconds to finish for val in buf: # loop over all values print(val) # print the value out |
|
相关推荐
|
|
579 浏览 1 评论
794 浏览 0 评论
MCU友好过渡MPU,米尔基于STM32MP135开发板裸机开发应用笔记
614 浏览 0 评论
自定义系统时钟频率后,用库函数和微带两种方式点亮LED灯,为什么灯的闪烁频率不一致?
1413 浏览 2 评论
1634 浏览 2 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-19 20:38 , Processed in 0.584750 second(s), Total 61, Slave 45 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号