Devices & Components
Arduino Nano
Solderless Breadboard Full Size
Capacitor 100 nF
Buzzer
Axial Fan, 12 VDC
Multi-Turn Precision Potentiometer- 10k ohms (25 Turn)
Resistor 100 ohm
9V battery (generic)
Linear Regulator (7805)
Jumper wires (generic)
MOSFET Transistor, Switching
Resistor 1k ohm
General Purpose Transistor NPN
Capacitor 100 µF
Gravity: Analog LM35 Temperature Sensor For Arduino
Hardware & Tools
Soldering Station, 110 V
Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Software & Tools
Arduino IDE
Project description
Code
LM35 Temperature Fan
arduino
copy and paste
1// Ramji Patel376 // 2// Arduino.cc // 3 4#include <LiquidCrystal.h> 5LiquidCrystal lcd(5,6,7,8,9,10); 6 7int tempPin = A4; // the output pin of LM35 8int fan = 3; // the pin where fan is 9int led = 12; // led pin 10int temp; 11int tempMin = 30; // the temperature to start the fan 0% 12int tempMax = 60; // the maximum temperature when fan is at 100% 13int fanSpeed; 14int fanLCD; 15int buzzer = 13; 16 17void setup() { 18pinMode(fan, OUTPUT); 19pinMode(led, OUTPUT); 20pinMode(tempPin, INPUT); 21lcd.begin(16,2); 22Serial.begin(9600); 23} 24 25void loop() 26{ 27temp = readTemp(); // get the temperature 28Serial.print( temp ); 29if(temp < tempMin) // if temp is lower than minimum temp 30{ 31fanSpeed = 0; // fan is not spinning 32analogWrite(fan, fanSpeed); 33fanLCD=0; 34digitalWrite(fan, LOW); 35} 36if((temp >= tempMin) && (temp <= tempMax)) // if temperature is higher than minimum temp 37{ 38fanSpeed = temp;//map(temp, tempMin, tempMax, 0, 100); // the actual speed of fan//map(temp, tempMin, tempMax, 32, 255); 39fanSpeed=1.5*fanSpeed; 40fanLCD = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD100 41analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed 42} 43 44if(temp > tempMax) // if temp is higher than tempMax 45{ 46digitalWrite(led, HIGH); // turn on led 47} 48else // else turn of led 49{ 50digitalWrite(led, LOW); 51} 52lcd.setCursor(0,0); 53lcd.print("TEMP: "); 54lcd.print(temp); // display the temperature 55lcd.print("C "); 56lcd.setCursor(0,1); // move cursor to next line 57lcd.print("FANS: "); 58lcd.print(fanLCD); // display the fan speed 59lcd.print("%"); 60 61} 62 63int readTemp() { 64 // get the temperature and convert it to celsius 65temp = analogRead(tempPin); 66return temp * 0.48828125; 67}
LM35 Temperature Fan
arduino
copy and paste
1// Ramji Patel376 // 2// Arduino.cc // 3 4#include <LiquidCrystal.h> 5LiquidCrystal 6 lcd(5,6,7,8,9,10); 7 8int tempPin = A4; // the output pin of LM35 9int fan 10 = 3; // the pin where fan is 11int led = 12; // led pin 12int temp; 13int tempMin 14 = 30; // the temperature to start the fan 0% 15int tempMax = 60; // 16 the maximum temperature when fan is at 100% 17int fanSpeed; 18int fanLCD; 19int 20 buzzer = 13; 21 22void setup() { 23pinMode(fan, OUTPUT); 24pinMode(led, OUTPUT); 25pinMode(tempPin, 26 INPUT); 27lcd.begin(16,2); 28Serial.begin(9600); 29} 30 31void loop() 32{ 33temp 34 = readTemp(); // get the temperature 35Serial.print( temp ); 36if(temp 37 < tempMin) // if temp is lower than minimum temp 38{ 39fanSpeed = 0; 40 // fan is not spinning 41analogWrite(fan, fanSpeed); 42fanLCD=0; 43digitalWrite(fan, 44 LOW); 45} 46if((temp >= tempMin) && (temp <= tempMax)) // if temperature 47 is higher than minimum temp 48{ 49fanSpeed = temp;//map(temp, tempMin, tempMax, 50 0, 100); // the actual speed of fan//map(temp, tempMin, tempMax, 32, 255); 51fanSpeed=1.5*fanSpeed; 52fanLCD 53 = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD100 54analogWrite(fan, 55 fanSpeed); // spin the fan at the fanSpeed speed 56} 57 58if(temp 59 > tempMax) // if temp is higher than tempMax 60{ 61digitalWrite(led, 62 HIGH); // turn on led 63} 64else // else turn of led 65{ 66digitalWrite(led, 67 LOW); 68} 69lcd.setCursor(0,0); 70lcd.print("TEMP: "); 71lcd.print(temp); 72 // display the temperature 73lcd.print("C "); 74lcd.setCursor(0,1); 75 // move cursor to next line 76lcd.print("FANS: "); 77lcd.print(fanLCD); 78 // display the fan speed 79lcd.print("%"); 80 81} 82 83int readTemp() 84 { 85 // get the temperature and convert it to celsius 86temp = analogRead(tempPin); 87return 88 temp * 0.48828125; 89}
Downloadable files
LM35 Temperature Fan
Copy my code and paste it on Your editor
LM35 Temperature Fan
Comments
Only logged in users can leave comments