This is a simple script to control your pwm fan on raspberry pi.
Here's how I wiring the PWM fan on pi:
English: Using Raspberry Pi to Control a PWM Fan and Monitor its Speed
中文:利用 Raspberry Pi 控制 PWM 風扇及轉速偵測