Timeline for ESP32 LED PWM fade not working?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 21 at 11:33 | comment | added | Lorenzo | @6v6gt I think it might've also been some weird combination of other problems too. I didn't mention it, but my led was a high current (higher than a small TH led) and was wired with a 30cm thin awg30 wire. Some capacitance / inductance / whatever big electronic word might've played a part ahaha | |
Apr 21 at 11:18 | comment | added | 6v6gt | Out of curiosity, I have just tried the OP's original code (with the minimal necessary changes) both on a Uno and an Espressif ESP32_C3 devkitC-02 (Arduino ESP32 Core 3.0.4) and cannot duplicate the problem. The ESP32 analogWrite() appears to have undergone a number of changes. I've looked briefly at the ESP32 analogWrite issue history on github (there are currently 56 entries) so I could imagine that the OP has got an unlucky combination of board and core release level. Having said that, hammering away at analogWrite() at loop speed does not seem a good idea. | |
Apr 21 at 9:22 | comment | added | Edgar Bonet |
That's indeed an "interesting" behavior! On AVR, you can analogWrite() as often as you want, and that doesn't break the PWM behavior.
|
|
S Apr 21 at 0:26 | review | First answers | |||
Apr 21 at 0:57 | |||||
S Apr 21 at 0:26 | history | edited | Lorenzo | CC BY-SA 4.0 |
added 2 characters in body
|
Apr 21 at 0:23 | vote | accept | Lorenzo | ||
Apr 21 at 0:22 | comment | added | Lorenzo | @6v6gt I mean, this is my only reasonable guess as why it would work with the delay honestly. As for the resistor, values for the led are in the diagram, the 22ohms was calculated for the original 5v (with a 0.3v drop from the transistor). I also did add a base resistor of 150ohm, kind of winged it as not too expert and all the calculators online seemed to give different results. Edited the diagram to add it. | |
Apr 21 at 0:10 | comment | added | 6v6gt | Interesting observation of esp32 analogWrite() behaviour. In that configuration you need a series base resistor on the transistor (say 680 ohms to 1k). With the previous emitter follower configuration a base resistor was unnecessary. Also, if 22 ohms for the led current limiting resistor was correct in the previous configuration, it will surely be too low in the current configuration where 5v instead of about 2.7v is available. It depends on the led's forward voltage and maximum current. | |
S Apr 20 at 22:47 | review | First answers | |||
Apr 20 at 23:01 | |||||
S Apr 20 at 22:47 | history | answered | Lorenzo | CC BY-SA 4.0 |