-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDControl.ino
53 lines (43 loc) · 1.17 KB
/
LEDControl.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "BLE.h"
#define WW_PIN 18
#define CW_PIN 19
int freq = 5000;
int wwChannel = 0;
int cwChannel = 1;
int resolution = 12;
BLE BT;
void setup() {
Serial.begin(115200);
Serial.print("HW v");
Serial.print(HARDWARE_VERSION_MAJOR);
Serial.print(".");
Serial.println(HARDWARE_VERSION_MINOR);
Serial.print("SW v");
Serial.print(SOFTWARE_VERSION_MAJOR);
Serial.print(".");
Serial.print(SOFTWARE_VERSION_MINOR);
Serial.print(".");
Serial.println(SOFTWARE_VERSION_PATCH);
Serial.println("Init BLE OTA");
BT.begin("ESP32 BLE OTA Updates");
Serial.println("Init LEDC driver");
ledcSetup(wwChannel, freq, resolution);
ledcSetup(cwChannel, freq, resolution);
ledcAttachPin(WW_PIN, wwChannel);
ledcAttachPin(CW_PIN, cwChannel);
Serial.println("Init LEDC driver completed.");
}
void loop() {
Serial.println("dimm up.");
for (int dutyCycle = 0; dutyCycle <= 4095; dutyCycle++) {
ledcWrite(wwChannel, dutyCycle);
ledcWrite(cwChannel, dutyCycle);
delay(7);
}
Serial.println("dimm down.");
for (int dutyCycle = 4095; dutyCycle >= 0; dutyCycle--) {
ledcWrite(wwChannel, dutyCycle);
ledcWrite(cwChannel, dutyCycle);
delay(7);
}
}