CPU Fan for a P.C.
Do you know that if your computer gets extremely hot it can be bad for the computer and even yourself? Here's how to fix it! (don't worry It will still look good)
Components and supplies
1
16x2 LCD display with I²C interface
1
Temperature Sensor: LM35dz
1
Arduino UNO R3 - Made in italy
1
10 jumper wires 150mm male
1
Breadboard 100x70
1
CPU fan 12 volt
Tools and machines
1
a laptop or a computer to test
Apps and platforms
1
Arduino IDE 2.0 (beta)
Project description
Code
4-speed cpu fan
js
1#include <LiquidCrystal_I2C.h> 2 3LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows 4 5// Pin Definitions 6const int tempPin = A0; // LM35 sensor output connected to A0 7const int fanPin = 9; // PWM pin connected to the fan (Pin 9 supports PWM) 8 9// Variables 10int tempReading = 0; // Variable to store the raw temperature reading 11float temperatureF = 0; // Temperature in Fahrenheit 12int fanSpeed = 0; 13 14void setup() 15{ 16 lcd.init(); // initialize the lcd 17 lcd.backlight(); 18 19 20 21 pinMode(A0, INPUT); 22 Serial.begin(9600); 23 pinMode(fanPin, OUTPUT); 24} 25 26void loop() 27{ 28 lcd.clear(); 29 if ((-40 + 0.878679 * (analogRead(A0) - 20)) >= 75) { 30 lcd.clear(); 31 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 32 lcd.setCursor(0, 0); 33 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 34 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 35 lcd.setCursor(0, 1); 36 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 37 lcd.setCursor(5, 0); 38 lcd.print("F"); 39 lcd.setCursor(5, 1); 40 lcd.print("C"); 41 lcd.setCursor(7, 0); 42 lcd.print("Fan Speed"); 43 lcd.setCursor(12, 1); 44 lcd.print("PWM"); 45 lcd.setCursor(8, 1); 46 lcd.print(fanSpeed); 47 fanSpeed = 100; 48 if ((-40 + 0.878679 * (analogRead(A0) - 20)) >= 80) { 49 lcd.clear(); 50 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 51 lcd.setCursor(0, 0); 52 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 53 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 54 lcd.setCursor(0, 1); 55 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 56 lcd.setCursor(5, 0); 57 lcd.print("F"); 58 lcd.setCursor(5, 1); 59 lcd.print("C"); 60 lcd.setCursor(7, 0); 61 lcd.print("Fan Speed"); 62 lcd.setCursor(12, 1); 63 lcd.print("PWM"); 64 lcd.setCursor(8, 1); 65 lcd.print(fanSpeed); 66 fanSpeed = 155; 67 if ((-40 + 0.878679 * (analogRead(A0) - 20)) >= 85) { 68 lcd.clear(); 69 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 70 lcd.setCursor(0, 0); 71 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 72 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 73 lcd.setCursor(0, 1); 74 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 75 lcd.setCursor(5, 0); 76 lcd.print("F"); 77 lcd.setCursor(5, 1); 78 lcd.print("C"); 79 lcd.setCursor(7, 0); 80 lcd.print("Fan Speed"); 81 lcd.setCursor(12, 1); 82 lcd.print("PWM"); 83 lcd.setCursor(8, 1); 84 lcd.print(fanSpeed); 85 fanSpeed = 200; 86 if ((-40 + 0.878679 * (analogRead(A0) - 20)) >= 90) { 87 lcd.clear(); 88 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 89 lcd.setCursor(0, 0); 90 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 91 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 92 lcd.setCursor(0, 1); 93 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 94 lcd.setCursor(5, 0); 95 lcd.print("F"); 96 lcd.setCursor(5, 1); 97 lcd.print("C"); 98 lcd.setCursor(7, 0); 99 lcd.print("Fan Speed"); 100 lcd.setCursor(12, 1); 101 lcd.print("PWM"); 102 lcd.setCursor(8, 1); 103 lcd.print(fanSpeed); 104 fanSpeed = 255; 105 } 106 delay(1000); 107 } 108 delay(1000); 109 } 110 delay(1000); // Wait for 2000 millisecond(s) 111 } 112 else { 113 lcd.clear(); 114 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 115 lcd.setCursor(0, 0); 116 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 117 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 118 lcd.setCursor(0, 1); 119 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 120 lcd.setCursor(5, 0); 121 lcd.print("F"); 122 lcd.setCursor(5, 1); 123 lcd.print("C"); 124 lcd.setCursor(7, 0); 125 lcd.print("Fan Speed"); 126 lcd.setCursor(12, 1); 127 lcd.print("PWM"); 128 lcd.setCursor(8, 1); 129 lcd.print(fanSpeed); 130 fanSpeed = 0; 131 delay(1000); // Wait for 2000 millisecond(s) 132 } 133 134 analogWrite(fanPin, fanSpeed); 135 Serial.print("Fan Speed: "); 136 Serial.println(fanSpeed); 137 138 139}
2-speed cpu fan
js
1#include <LiquidCrystal_I2C.h> 2 3LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows 4 5// Pin Definitions 6const int tempPin = A0; // LM35 sensor output connected to A0 7const int fanPin = 9; // PWM pin connected to the fan (Pin 9 supports PWM) 8 9// Variables 10int tempReading = 0; // Variable to store the raw temperature reading 11float temperatureF = 0; // Temperature in Fahrenheit 12int fanSpeed = 0; 13 14void setup() 15{ 16 lcd.init(); // initialize the lcd 17 lcd.backlight(); 18 19 20 21 pinMode(A0, INPUT); 22 Serial.begin(9600); 23 pinMode(fanPin, OUTPUT); 24} 25 26void loop() 27{ 28 lcd.clear(); 29 if ((-40 + 0.878679 * (analogRead(A0) - 20)) >= 70) { 30 lcd.clear(); 31 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 32 lcd.setCursor(0, 0); 33 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 34 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 35 lcd.setCursor(0, 1); 36 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 37 lcd.setCursor(5, 0); 38 lcd.print("F"); 39 lcd.setCursor(5, 1); 40 lcd.print("C"); 41 lcd.setCursor(7, 0); 42 lcd.print("Fan Speed"); 43 lcd.setCursor(12, 1); 44 lcd.print("PWM"); 45 lcd.setCursor(8, 1); 46 lcd.print(fanSpeed); 47 fanSpeed = 155; 48 if ((-40 + 0.878679 * (analogRead(A0) - 20)) >= 80) { 49 lcd.clear(); 50 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 51 lcd.setCursor(0, 0); 52 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 53 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 54 lcd.setCursor(0, 1); 55 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 56 lcd.setCursor(5, 0); 57 lcd.print("F"); 58 lcd.setCursor(5, 1); 59 lcd.print("C"); 60 lcd.setCursor(7, 0); 61 lcd.print("Fan Speed"); 62 lcd.setCursor(12, 1); 63 lcd.print("PWM"); 64 lcd.setCursor(8, 1); 65 lcd.print(fanSpeed); 66 fanSpeed = 255; 67 } 68 delay(2000); // Wait for 2000 millisecond(s) 69 } 70 else { 71 lcd.clear(); 72 Serial.println((-40 + 0.878679 * (analogRead(A0) - 20))); 73 lcd.setCursor(0, 0); 74 lcd.print((-40 + 0.878679 * (analogRead(A0) - 20))); 75 Serial.println((-40 + 0.488155 * (analogRead(A0) - 20))); 76 lcd.setCursor(0, 1); 77 lcd.print((-40 + 0.488155 * (analogRead(A0) - 20))); 78 lcd.setCursor(5, 0); 79 lcd.print("F"); 80 lcd.setCursor(5, 1); 81 lcd.print("C"); 82 lcd.setCursor(7, 0); 83 lcd.print("Fan Speed"); 84 lcd.setCursor(12, 1); 85 lcd.print("PWM"); 86 lcd.setCursor(8, 1); 87 lcd.print(fanSpeed); 88 fanSpeed = 0; 89 delay(2000); // Wait for 2000 millisecond(s) 90 } 91 92 analogWrite(fanPin, fanSpeed); 93 Serial.print("Fan Speed: "); 94 Serial.println(fanSpeed); 95 96 97}
Documentation
schematic
Brave Bigery-Robo (1).png

Comments
Only logged in users can leave comments