ESP32 Source code on the bottom of this article!
See the original complete project tutorial here: Android RGB LED Arduino Controller
In September 2014, I created this project with Arduino Mini Pro Mini and Android APP loved by so many readers! There are more than 100,000 App downloads by now! Since then, quite of few readers asked me how to change the sketch to be used on ESP32 with built-in Bluetooth. Here it is!! 😀
Be aware that LED PWM pins used on ESP32 were completely different, since Arduino Mini Pro and ESP32 have different architectures.
For ESP32, I used following pins:
- Pin 13 = Red
- Pin 12 = Green
- Pin 14 = Blue
Caution: ESP32 does not allow to use pin 6, 7, 8, 9, 10, 11 or it will crash and reboot. I tried...😂
Also, there is no analogWrite() function in ESP32, so I need to change analogWrite() to ledcWrite() with
- Channel definition for PWM
- R channel = 0
- G channel = 1
- B channel = 2
- Setup PWM frequency: 5000
- Setup PWM resolution: 8 (8bit = 255 colors)
Then I need to setup LED with:
- ledcSetup( channel, frequency, resolution)
And then attach LED pins to channel
- ledcAttachPin(Pin, channel)
Then write to LED pins with
- ledcWrite( channel, value for resolution(0~255));
END
