Can I control the speed of motors and fans with a PWM signal?

Yes, as long as you have the proper hardware to do that. The PWM signal being produced should be handled appropriately, whether by a fast-switching solid state relay, AC modulation circuitry, DC modulation circuitry, or something else.

Some fans, such as the EC duct fans made by terrabloom can have their speed controlled by a PWM signal, although they require a 10 - 12 DC volt signal rather than the 3.3 or 5 volt signal a single board computer or microcontroller can output. Circuitry needs to be developed to convert this low voltage to the higher voltage needed by the fan. The following schematic with 2 NPN transistors and a few resistors can do just that, with an additional bonus of being able to read the tachometer wire coming from the fan to also measure the fan RPM:

I used this schematic to develop a circuit board that can be found at Oshpark, which can also be ordered to be printed through the link. Please read the description after following the link for the details of how to use the circuit board after being made.

3 Likes