第1步:您需要的零件
我用來執行此操作的零件
·Genuino UNO
·溫度傳感器–關鍵部件
·1KΩ電阻器
·100μF/16V電容器
·PN2222A NPN晶體管–打開風扇的關鍵部分
·12V DC無刷風扇–關鍵部分
·1N4007二極管
·AC – DC插入適配器120VAC至12VDC
·液晶顯示器
·額外面包板
步驟2:示意圖

步驟3:源代碼//注釋
#include
// library for LCD LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float temp; // set temp as a whole number
int tempPin = A0; //arduino pin used for temperature sensor
int tempMin = 23; // the temperature to start the buzzer
int tempMax = 26; // temperature full speed
int fan = 6; // the pin where fan is connected
int fanSpeed = 0; // fan speed variable void setup() {
pinMode(fan, OUTPUT); // declaring fan pin 6 as output
pinMode(tempPin, INPUT); // declaring tempPin A0 as input
lcd.begin(16, 2); // LCD intialize
lcd.clear(); // clears lcd
lcd.print(“Fan Speed:”); // prints “Fan Speed” 50-255 PWM
lcd.setCursor(0,1); // Sets cursor for next line
lcd.print(“Temperature:”); // Prints “Temperature” below “Fan Speed”
Serial.begin(9600); // begins the serial monitor
} void loop() {
float voltage = (temp/1024)*5.0;
float temperature = (voltage - 0.5) * 100; // formula for degrees celcius
Serial.println(temperature); // prints temp in serial monitor
lcd.setCursor(12,1); // 12 character to the right on the first column
lcd.print(temperature); // prints the number on the 12 character
delay(1000); // delay in between reads for stability
if(temp 《 tempMin) { // if temp is lower than minimum temp
fanSpeed = 0; // fan is not spinning
digitalWrite(fan, LOW); // pin 6 output is low
}
if((temperature 》= tempMin) && (temperature 《= tempMax)) //if temperature is higher than the minimmum range
{
fanSpeed = map(temperature, tempMin, tempMax, 50, 255); // the actual speed of fan
analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
Serial.println(fanSpeed); // prints fan speed in serial monitor
lcd.setCursor(12,0); // sets cursor
lcd.print(fanSpeed); // prints
lcd.print(“ ”); // fixes an error of random number display
}
}
責任編輯:wv
-
溫控
+關注
關注
0文章
82瀏覽量
19345 -
風扇
+關注
關注
4文章
446瀏覽量
39352
發布評論請先 登錄
深入解析MAX6660:遠程結溫控制的風扇調速利器
LM96163遠程二極管數字溫度傳感器:精準溫控與智能風扇控制的完美結合
散熱風扇如何守護智慧大棚與垂直農場
3D打印機散熱風扇:熱管理核心與選型優化指南
電能質量在線監測裝置高溫下風扇自動啟停嗎?
FeRAM在溫控器中的應用優勢
關于散熱風扇與散熱風扇轉子你了解多少?
浮思特 | 離心風扇與軸流風扇區別——美蓓亞三美散熱方案解析
電熨斗恒溫熨燙:鋁電解電容幫溫控模塊穩住電壓波動
風扇燈PCBA方案開發原理及介紹
風扇應用的升壓芯片到底怎么選?升壓芯片又是如何驅動風扇的?
溫控風扇的制作
評論