中秋節在家寫code
祝大家中秋節快樂
#include <analogWrite.h> //請安裝ESP32 AnalogWrite程式庫
void setup() {
Serial.begin(115200);
pinMode(15, OUTPUT);
}
void loop() {
Serial.println("由暗變亮");
for (int i = 0; i <= 255; i++) {
analogWrite(15, i);//亮度i從0->255
delay(10);
}
delay(1000);
Serial.println("由亮變暗");
for (int i = 255; i >= 0; i--) {
analogWrite(15, i); //亮度i從255->0
delay(10);
}
delay(1000);
}
https://wokwi.com/projects/340306867104252499