Controlling PC cooling fan that has a PWM input

btw the code as written assumes that the Arduino is connected to the pwm fan input via an opto isolator or npn transistor that pulls the pwm input low when the Arduino pin is high. If you connect it directly, then the speed control will work in reverse, unless you change the counter timer mode from "inverted fast pwm" to "fast pwm".