esp32默认不能直接输出模拟量,得调用库文件
案例如下:
#include <Arduino.h>
#include <analogWrite.h>
int step = 1;
int brightness = 0;
void setup() {
}
void loop() {
brightness += brightStep;
analogWrite(LED_BUILTIN, brightness);
if ( brightness == 0 || brightness == 255 ) {
brightStep = -brightStep;
}
delay(10);
}