This project is to demonstrate how to use a PWM pin to adjust the speed of a DC fan. The modulated signal from the Arduino PWM pin we use to activate a MOSFET, which then from this MOSFET gives power to the fan corresponds to the signal intensity of the PWM pin.
to adjust the speed digitally can see on https://arduinoproyek.wordpress.com/2018/10/15/speed-control-dc-fan/
#define fadePin 3 // PWM pin
int pot = A2;
int t2 = 0;
//calculate sin of angle as number between 0 and 255
float t2= analogRead(pot);
int sinOut = t2*255/1023;