物联网开发108 - Micropython ESP32 C3-ADC采集模拟量滑动电位器&PWM调速舵机角度控制_esp32c3模拟器

adc.py

from machine import Pin,SoftI2C,PWM,ADC
from ssd1306 import SSD1306_I2C

from ufont import BMFont
import time

i2c  = SoftI2C(scl = Pin(2),sda = Pin(3),freq = 400_000)
oled = SSD1306_I2C(128,64,i2c,0x3c)

#freq = 40Mhz duty = 1023 4095 获取的值/最带宽带12bit4095 * 1023
motora = PWM(Pin(8),duty=(0),freq = 4095)  #4.095khz   #风扇
motorb = PWM(Pin(6),duty=(0),freq = 50)  #50hz 1/20=50 #舵机

font = BMFont("fonts/unifont-14-12888-16.v3.bmf")

adc = ADC(Pin(5))
adc.atten(ADC.ATTN_11DB)
adc.width(ADC.WIDTH_12BIT)  #4095

def main():
  
    font.text(oled,"电压值:",0,16, color=1,font_size=16,reverse=False,clear=False,show=True,half_char=True, auto_wrap=True)
    font.text(oled,"模拟值:",0,32, color=1,font_size=16,reverse=False,clear=False,show=True,half_char=True, auto_wrap=True)
    font.text(oled,"角度值:",0,48, color=1,font_size&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值