Led dimmer without any ADC input from STM32 dev board

Hello Everyone!!
I hope you are all going well.
A couple of months ago I dimmed a led with PWM by using a potentiometer rotation in order to monitor the brightness of the Led with STM32 board.
Now I want to control the brightness of the Led without any potentiometer.
As a matter of fact, From a 100% of the brightness of my Led, I want to be able to lower this brighness atleast at 25% without any potentiometer. The code that I have doesn’t allow me to reach it out.

Any help is welcome.

Thanks in advance

Do you mean, you want to remove the potentiometer from your already existing code and modify the code in such a way that the brightness of the LED is maintained at 25%?? If that is the case, please post your code.

1 Like

Yes that’s it.
Please find bellow my code based on the PWM.

int duty_c;

		for (duty_c = 0; duty_c < 100; duty_c++)
		{
			__HAL_TIM_SET_COMPARE(&htim12, TIM_CHANNEL_1, (duty_c)*400);
			HAL_Delay(100);
		}
	
		for (duty_c = 100; duty_c >= 0; duty_c--)
		{
			__HAL_TIM_SET_COMPARE(&htim12, TIM_CHANNEL_1, (duty_c)*400);
			HAL_Delay(100);
		}