Use Portc.1 or Portc.2 and HPWM (see page 73 of the manual)




B0 var Byte
Vduty var Byte

Vduty=0
B0=1

Main:

if UpButton =0 then
If Vduty<255 Then Vduty=Vduty+B0
Gosub HpwmSet
endif

if DownButton =0 then
If Vduty>0 then Vduty=Vduty+B0
Gosub HpwmSet
endif

goto Main


HpwmSet:
HPWM Channel, Vduty,Frequency
Return

with B0 = 1 you have 255 steps , if you want 10 steps set B0 = 25

UpButton and DownButton are two input ports with a 10K resistor pullup, the switch is normally open.

Al.