User manual

366
mikoPascal PRO for PIC32
MikroElektronika
PWM_Set_Duty(current_duty, 1); // set newly acquired duty ratio
end;
if RB2_bit = 1 then // button on RB2 pressed
begin
Delay_ms(1);
current_duty1 := current_duty1 + 5; // increment current_duty1
if (current_duty1 > pwm_period2) then // if we increase current_duty1 greater
then possible pwm_period2 value
current_duty1 := 0; // reset current_duty1 value to zero
PWM_Set_Duty(current_duty1, 2); // set newly acquired duty ratio
end;
if RB3_bit = 1 then // button on RB3 pressed
begin
Delay_ms(1);
current_duty1 := current_duty1 - 5; // decrement current_duty
if (current_duty1 > pwm_period2) then // if we decrease current_duty1 greater
then possible pwm_period1 value (overow)
current_duty1 := pwm_period2; // set current_duty to max possible value
PWM_Set_Duty(current_duty1, 2);
end;
Delay_ms(2); // slow down change pace a little
end;
end.
HW Connection
PWM demonstration