match ledcWrite_RGB example in esp32 docs

This commit is contained in:
brentru 2023-10-11 15:12:31 -04:00
parent 0f94088d28
commit 140f13febc
2 changed files with 4 additions and 6 deletions

View file

@ -30,8 +30,7 @@ void setup() {
// set up led pin as an analog output
#if defined(ARDUINO_ARCH_ESP32)
// ESP32 pinMode()
ledcAttachPin(LED_PIN,analogGetChannel(LED_PIN));
ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
#else
pinMode(LED_PIN, OUTPUT);
#endif

View file

@ -39,10 +39,9 @@ void setup() {
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
// assign rgb pins to channels
ledcAttachPin(RED_PIN,analogGetChannel(RED_PIN));
ledcAttachPin(GREEN_PIN,analogGetChannel(GREEN_PIN));
ledcAttachPin(BLUE_PIN,analogGetChannel(BLUE_PIN));
ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
ledcAttach(GREEN_PIN, 12000, 8);
ledcAttach(BLUE_PIN, 12000, 8);
#else
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);