欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
ESP32產(chǎn)生PWM的Arduino程序
[打印本頁(yè)]
作者:
EdwardGU123
時(shí)間:
2022-12-28 12:41
標(biāo)題:
ESP32產(chǎn)生PWM的Arduino程序
const int ledPin = 2; // PWM生成后實(shí)際輸出引腳
//設(shè)置PWM參數(shù)
const int freq = 4000;//PWM頻率
const int ledChannel = 0;//信號(hào)生成GPIO
const int resolution = 12;//12位分辨率,by Jason. 可設(shè)置1~14bits
void setup(){
//PWM參數(shù)設(shè)置
ledcSetup(ledChannel, freq, resolution);
//將生成信號(hào)通道綁定到輸出通道上
ledcAttachPin(ledPin, ledChannel);
}
void loop(){
//逐漸變亮,12位分辨率因而到4096
for(int dutyCycle = 0; dutyCycle <= 123;dutyCycle++){
// changing the LED brightness withPWM
ledcWrite(ledChannel, dutyCycle);
delay(20);
}
//逐漸變暗
for(int dutyCycle = 123; dutyCycle >= 0;dutyCycle--){
// changing the LED brightness with PWM
ledcWrite(ledChannel,dutyCycle);
delay(20);
}
}
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1