@@ -40,13 +40,9 @@ void setup() {
40
40
41
41
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
42
42
// assign rgb pins to channels
43
- ledcAttachPin (RED_PIN, 1 );
44
- ledcAttachPin (GREEN_PIN, 2 );
45
- ledcAttachPin (BLUE_PIN, 3 );
46
- // init. channels
47
- ledcSetup (1 , 12000 , 8 );
48
- ledcSetup (2 , 12000 , 8 );
49
- ledcSetup (3 , 12000 , 8 );
43
+ ledcAttachPin (RED_PIN,analogGetChannel (RED_PIN));
44
+ ledcAttachPin (GREEN_PIN,analogGetChannel (GREEN_PIN));
45
+ ledcAttachPin (BLUE_PIN,analogGetChannel (BLUE_PIN));
50
46
#else
51
47
pinMode (RED_PIN, OUTPUT);
52
48
pinMode (GREEN_PIN, OUTPUT);
@@ -108,14 +104,7 @@ void handleMessage(AdafruitIO_Data *data) {
108
104
Serial.println (data->value ());
109
105
110
106
// invert RGB values for common anode LEDs
111
- #if defined(ARDUINO_ARCH_ESP32) // ESP32 analogWrite
112
- ledcWrite (1 , 255 - data->toRed ());
113
- ledcWrite (2 , 255 - data->toGreen ());
114
- ledcWrite (3 , 255 - data->toBlue ());
115
- #else
116
- analogWrite (RED_PIN, 255 - data->toRed ());
117
- analogWrite (GREEN_PIN, 255 - data->toGreen ());
118
- analogWrite (BLUE_PIN, 255 - data->toBlue ());
119
- #endif
120
-
107
+ analogWrite (RED_PIN, 255 - data->toRed ());
108
+ analogWrite (GREEN_PIN, 255 - data->toGreen ());
109
+ analogWrite (BLUE_PIN, 255 - data->toBlue ());
121
110
}
0 commit comments