You’re driving on an unfamiliar road, google maps is telling you to take the next left coming up but it’s late at night, you can’t see the turnoff. You have Unholy by Sam Smith blasting out of the speakers. You instinctively turn down the dial as to see the road better. The sensory overload of the sound and focused brain activity made me think of the following simple project.
I connected an LED to my ESP-32. I then configured my ESP-32 to be a bluetooth receiver for my iPhone to send music to. I then inversely mapped my volume to the brightness of the LED. The LED used the CIE1931 fade curve which made it feel like more of a natural fade as compared to a pure linear mapping where it feels like it reaches it’ apex quickly.
Turn down the sound to see better!
Read on to hear about the difficulties I had to get the fade to work on the ESP-32.
I initially ran into difficulties programming this onto my ESP-32 because running analogWrite()
didn’t work. I found out that instead I had to use the ledcWrite()
function. This function requires 2 parameters:
analogWrite()