Hello,
Based on this video:
and code:
int sensorPin = A0;
int PWM = 3;
int sensorVal;
int PWMVal;
void setup() {
// put your setup code here, to run once:
pinMode(sensorPin, INPUT);
pinMode(PWM, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
//this code prints sensor value to the console
Serial.println(sensorVal);
delay(1000);
//read sensor value and set upper limit cap
sensorVal = analogRead(sensorPin);
if(sensorVal >800){
sensorVal = 800;
}
//map and assign pwm values to the fan output 0 to 255 corresponds to 0 to 100%
PWMVal = map(sensorVal, 450, 800, 26, 255);
//set 450 as out cutout or cut in limit where the fan switches from off to the lower PWM limit
if(sensorVal <450){
PWMVal = 0;
}
//write the PWM value to the pwm output pin
analogWrite(PWM, PWMVal);
}
and the fact that:
The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button.
I planning an (at least 4 channel, but possibly even 8 channel) fan controller for regular 3 wire PC fans (not 4 wire) with an Arduino Mega.
In the video he mentions that the MOSFET he is using might not be the best for this application so anyone can recommend something better?
Also what do you think of the practice that he puts the MOSFET into the GROUND line instead of the positiv line for the fan?
In conjunction with another article where someone control a 4 pin fan (which meant to be pwm controlled on pin4) he notes:
Intel's specification for 4-pin fans suggests a 25KHz target PWM frequency and 21 kHz to 28 kHz acceptable range. The problem is that Arduino's default frequency is 488Hz or 976Hz, but the ATMega 32u4 is perfectly capable of delivering higher frequencies, so we only need to set it up correctly.
So is this now applies to my case? In the first build he does no tricks to increase the frequency of the PWM pins?