Which Arduino?
At what temperature will the fan run full speed?
At what temperature will the fan run minimum speed?
How will you determine temperature?
What is the temperature sensor that you will use? Post a data sheet.
To get you started.
Connect the fan as follows. Board is Uno.
1 - 12v >> 12V
2 - GND >> 12V supply ground and Arduino ground
2 - Signal >> Arduino pin 3 to measure revolutions per second
4 - PWM >> Arduino pin 5 to control speed
I don't know what temperature sensor that you have so will simulate a sensor with a potentiometer. Connect a 1K to 100K pot wiper to pin A0 (and to Arduino 5V and ground). See here.
Adjust the speed with the pot. View the speed (revs/second) in serial monitor.
Then you need to answer the questions asked by @ JCA34F.
The answers will tell you how you have to scale the PWM numbers (0 to 255) to get the fan speed that you want versus temperature.
Use the pot to see how speed relates to PWM. Like PWM = 0 means x revs/second and PWM = 255 means y revs/second.
I use ESP32
Full speed would be at 27 degrees
Minimum speed would be at 22 degrees
(ideal temperature to keep is 22 degrees)
And I will determine temperature with the temperature sensor (DS18B20).
Is it the room temperature?
If the ambient temperature is 27degrees, a fan will not bring the temperature down to 22 degrees - it just blows 27 degrees air around.
or is it a semiconductor on a heatsink, with the ambient temperature at 22 degrees or less?