I have a PWM fan connected to pin 18 What is the simplest way to make the fan turn on at 50 degrees and turn off when the temperature drops to 35 degrees.
1 Answer
https://raspberrypi.stackexchange.com/a/133849/8697 explains how to turn a fan on/off at a given temperature.
Normally PWM fans use varied speeds but these need a controller and there are Device Tree overlays for these.
I am not aware of any existing code using GPIO pins - you really don't need to use hardware PWM.
The Pi5 has an inbuilt fan control.