Page 1 of 1
Is it possible to customise the duty cycle setting in this demo?
Posted: Tue Jun 17, 2025 8:57 pm
by canary_wharfe
Got the PWM working in Lorlin32 Lite at my target Fq. of 1Hz.
The thing is any PWM Set Duty Cycle macro I use appears to get over-ridden by the low level settings in the component PWM. In the current code I get a duty-cycle of 50% which I can live with but would have preferred to have custom control over the duty cycle e.g. 20/80 mark / space. Is there an easy way of doing this and still retain my 1Hz PWM Fq? TIA.
Re: Is it possible to customise the duty cycle setting in this demo?
Posted: Wed Jun 18, 2025 2:12 pm
by medelec35
Hello.
I have modified your project so PWM duty ranges from 0 to 100% when POT ranges 0 - 4095
The PWM duty is only set when the pot changes value.
If pot value is too unstable on ESP32, use the GetAverageInt function instead
Re: Is it possible to customise the duty cycle setting in this demo?
Posted: Wed Jun 18, 2025 11:05 pm
by canary_wharfe
Thanks Martin. That is a very elegant bit of code. Thanks also for introducing me to the maths map component. I have managed to pull out snippets of your demo and get the PWM duty cycle function working now.

Re: Is it possible to customise the duty cycle setting in this demo?
Posted: Thu Jun 19, 2025 8:03 am
by medelec35
You're welcome, that's great!
I'm glad I have helped you to continue your project.
Re: Is it possible to customise the duty cycle setting in this demo?
Posted: Fri Aug 15, 2025 1:01 pm
by chipfryer27
Hi
Has anything happened with the ESP Lolin-Lite or PWM?
Not geting anything on a scope when I use components / properties in above post by Martin, but it does simulate.
Regards
Re: Is it possible to customise the duty cycle setting in this demo?
Posted: Mon Aug 18, 2025 1:50 pm
by medelec35
Hi Iain .
Sorry for the delay.
I have just tested Lolin lite and PWM output is working as expected.
Attached is the project I had used.
I have included it as I have changed pins since the file attached above .
Re: Is it possible to customise the duty cycle setting in this demo?
Posted: Mon Aug 18, 2025 2:35 pm
by chipfryer27
Hi Martin
Thanks.
My chart was based on the previous example and was only to enable the PWM, no need to vary Duty. I just wanted an output. It used same pins but I couldn't get anything on scope.
I'll try again based on your reply above and let you know how I get on.
Regards