if ur fan is consuming low current. u can use L293/ L293D as the driver. u can control 4 fans by using this IC since it has 4 half bridge. u can use BJT oso if ur current is very small, as small as mili amperes.
the PWM code is dependent on the controller u are using. u can refer the datasheet to get the configuration correct. normally u will need to set the CCPCONX and TIMER 2/4/6 configuration register.
changing the pWM duty cycle by loading CCPR register. and PWM frequency is set by using PR register of the timer. u selected.