Skip to content

Commit 140f13f

Browse files
committed
match ledcWrite_RGB example in esp32 docs
1 parent 0f94088 commit 140f13f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

examples/adafruitio_09_analog_out/adafruitio_09_analog_out.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ void setup() {
3030

3131
// set up led pin as an analog output
3232
#if defined(ARDUINO_ARCH_ESP32)
33-
// ESP32 pinMode()
34-
ledcAttachPin(LED_PIN,analogGetChannel(LED_PIN));
33+
ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
3534
#else
3635
pinMode(LED_PIN, OUTPUT);
3736
#endif

examples/adafruitio_13_rgb/adafruitio_13_rgb.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ void setup() {
3939

4040

4141
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
42-
// assign rgb pins to channels
43-
ledcAttachPin(RED_PIN,analogGetChannel(RED_PIN));
44-
ledcAttachPin(GREEN_PIN,analogGetChannel(GREEN_PIN));
45-
ledcAttachPin(BLUE_PIN,analogGetChannel(BLUE_PIN));
42+
ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
43+
ledcAttach(GREEN_PIN, 12000, 8);
44+
ledcAttach(BLUE_PIN, 12000, 8);
4645
#else
4746
pinMode(RED_PIN, OUTPUT);
4847
pinMode(GREEN_PIN, OUTPUT);

0 commit comments

Comments
 (0)