1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| #include <Arduino.h>
const int LED = 2,
CH = 0,
FREQ = 5000,
RES = 8;
void setup() {
ledcSetup(CH, FREQ, RES);
ledcAttachPin(LED, CH);
}
void loop() {
for (int d = 0; d <= 255; ++d) {
ledcWrite(CH, d);
delay(5);
}
for (int d = 255; d >= 0; --d) {
ledcWrite(CH, d);
delay(5);
}
}
|