User manual

376
mikoBasic PRO for PIC32
MikroElektronika
if RB2_bit = 1 then ‘ button on RB2 pressed
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
end if
PWM_Set_Duty(current_duty1, 2) ‘ set newly acquired duty ratio
end if
if RB3_bit = 1 then ‘ button on RB3 pressed
Delay_ms(1)
current_duty1 = current_duty1 - 5 ‘ decrement current_duty1
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
end if
PWM_Set_Duty(current_duty1, 2)
end if
Delay_ms(1) ‘ slow down change pace a little
wend
end.
HW Connection
PWM demonstration