Continue to Site

Reply to thread

Instead of stopping at 32767, let the duty cycle reach 65535 and see if the problem still persists.

[CODE]unsigned int duty;

void main() {

    TRISD = 0x0;  // Set PORTD as output

    duty = 0;


    PWM1_MC_Init(5000, 0, 0x11, 0);

    PWM1_MC_Set_Duty(duty, 1);

    PWM1_MC_Start();


    while (1) {

        // Increase brightness

        while (duty < 65535) {

            duty++;

            PWM1_MC_Set_Duty(duty, 1);

            delay_ms(5);  // Slightly longer delay for smooth transition

        }


        // Decrease brightness

        while (duty > 0) {

            duty--;

            PWM1_MC_Set_Duty(duty, 1);

            delay_ms(5);

        }

    }

}

[/CODE]


Part and Inventory Search

Back
Top