I presume that you have a circuit with:

1. A variable resistor, say 10k, connected to +5 Volts.
2. A capacitor, say 0.1mfd, connected to the the other end of the variable resistor and ground.
3. The wiper of the pot/variable resistor connected to pin A.0.

'Duty' should be a BYTE sized variable.
'Scale' is used to get the best results. Try Scale=127, to start.

The value of 'Duty' will be proportional to the setting of the variable resistance.

See page 118 of the PBP handbook

Regards Bill legge