As the title says, I want to control the fan speed of a PWM Noctua 140mm Fan using an Arduino UNO.
My application simply requires me to be able to change the fan speed/RPM from completely off, to some intermediate values, to max speed.
My current equipment is:
Benchtop Power Supply
Arduino UNO
PWM Noctua Fan
Wires
With respect to the wiring, I know that the 4-wires in my PWM fan correspond to the following:
BLACK---GND
YELLOW---12V
GREEN---TACHOMETER
BLUE---PWM
Therefore, I connected the BLUE wire into the Number 3 Pin in the Digital I/O portion of the Arduino UNO. (I've also tried to connect the PWM wire to the 5,6,9,10, and 11 pins but to no avail)
The GREEN wire is currently unused. The YELLOW wire is connected directly to my power supply. The BLACK wire is currently connected to the power supply and I have also ensured that the Arduino shares a common ground with it.
This guy is basically doing what I'm trying to accomplish in this video:
My project is much simpler than what he did. First of all, I just need to control 1 fan instead of the 5 fans he did. Second, I have no need for the LED part he used.
I took his source code, which can be found here: (arduino-pwm-fan-serial-control--for-tuning-/fan_serial_commander.ino at master · catalystoftechnology/arduino-pwm-fan-serial-control--for-tuning- · GitHub)
And modified it to better suit my project. This is the code I used:
int fanSpeed = 0;
String command;
char werd;
int currentFan = 0;
int fan = 6;
int frontSpeed = 0;
int commandCheck;
String frontMarker = "-> ";
void setup() {
pinMode(6, OUTPUT);
analogWrite(6,0);
Serial.begin(9600);
Serial.println();
}
void loop(){
while ( Serial.available() > 0 ) {
delay(5);
werd = Serial.read();
command += werd;
}
Serial.flush();
if ( command.length() > 0 ) {
commandCheck = 0;
if ( command == "front" ) {
currentFan = 0;
frontMarker = "-> ";
} else {
commandCheck = 1;
}
if ( commandCheck == 1 ) {
if ( currentFan == 0 ) {
//front
analogWrite(fan, command.toInt());
frontSpeed = command.toInt();
}else {
}
}
command = "";
Serial.print(frontMarker);
Serial.print("Front: ");
Serial.println(frontSpeed);
clear();
}
}
void clear() {
Serial.println();
}
I've gone through a myriad of variations on that code and others that I've found online but none seem to work.
First, I connect my fan, Arduino and PSU as stated above. Then, I give my fan 12V with the PSU which causes the fan to start rotating. Then, I upload the code into the Arduino UNO.
I've tried both his code and mine. When I go to the Serial Monitor I can change the numerical value of the speeds just fine. However, I observe absolutely no change in the speed of the fans regardless of the value I input in the serial monitor.
Please let me know any suggestions, corrections, and/or ideas you have. I'm currently at a standstill with this, and has halted my research. This is my first time using Arduino so I'm still getting used to the syntax and the electronics, so I apologize if I ask any elementary questions.
Thank you in advance for any and all help!