最新免费av在线观看,亚洲综合一区成人在线,中文字幕精品无码一区二区三区,中文人妻av高清一区二区,中文字幕乱偷无码av先锋

風(fēng)扇速度由溫度和Arduino控制

出處:維庫(kù)電子市場(chǎng)網(wǎng) 發(fā)布于:2024-08-01 17:41:32 | 389 次閱讀

  可以根據(jù) LM35 傳感器讀取的溫度自動(dòng)控制直流風(fēng)扇的速度。我在使用PWM部分時(shí)遇到了一些問(wèn)題,主要是因?yàn)轱L(fēng)扇發(fā)出了令人不安的噪音,所以我不得不在Arduino板上的PWM引腳輸出端添加一個(gè)簡(jiǎn)單的RC濾波器?! ∽詣?dòng)風(fēng)扇轉(zhuǎn)速控制器原理圖

  Arduino溫度風(fēng)扇速度控制
  LM35 數(shù)據(jù)表
  Arduino草圖
  #include <LiquidCrystal.h>
  //source: https://www.electroschematics.com/9540/arduino-fan-speed-controlled-temperature/
  LiquidCrystal lcd(7,6,5,4,3,2);
  int tempPin = A1;   // the output pin of LM35
  int fan = 11;       // the pin where fan is
  int led = 8;        // led pin
  int temp;
  int tempMin = 30;   // the temperature to start the fan
  int tempMax = 70;   // the maximum temperature when fan is at 100%
  int fanSpeed;
  int fanLCD;
  void setup() {
  pinMode(fan, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(tempPin, INPUT);
  lcd.begin(16,2);
  }
  void loop() {
  temp = readTemp();     // get the temperature
  if(temp  < tempMin) { // if temp is lower than minimum temp
  fanSpeed = 0; // fan is not spinning
  digitalWrite(fan, LOW);
  }
  if((temp  >= tempMin) && (temp <= tempMax)) { // if temperature is higher than minimum temp
  fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan
  fanLCD = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD
  analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
  }
  if(temp  > tempMax) {        // if temp is higher than tempMax
  digitalWrite(led, HIGH);  // turn on led
  } else {                    // else turn of led
  digitalWrite(led, LOW);
  }
  lcd.print("TEMP: ");
  lcd.print(temp);      // display the temperature
  lcd.print("C ");
  lcd.setCursor(0,1);   // move cursor to next line
  lcd.print("FANS: ");
  lcd.print(fanLCD);    // display the fan speed
  lcd.print("%");
  delay(200);
  lcd.clear();
  }
  int readTemp() {  // get the temperature and convert it to celsius
  temp = analogRead(tempPin);
  return temp * 0.48828125;  }

  測(cè)試設(shè)置
  我使用LCD屏蔽來(lái)顯示風(fēng)扇的當(dāng)前溫度和速度,但是您可以使用沒(méi)有LCD顯示器的電路。您還需要根據(jù)您使用的風(fēng)扇類(lèi)型來(lái)選擇晶體管。就我而言,我使用著名的 BD139 晶體管和 9V 電池為風(fēng)扇和晶體管供電。LM35 溫度傳感器和紅色 LED 由 Arduino 板的 5V 電壓供電。
  電路是如何工作的?
  正如您在第一行的草圖中看到的,我包含了 LiquidCrystal 庫(kù)(標(biāo)頭),其中包含在將 LCD 連接到 Arduino 板時(shí)可以使用的有用功能。然后,我為傳感器、LED 和風(fēng)扇設(shè)置了引腳。
  最重要的部分是使用所需的值設(shè)置變量 tempMin 和 tempMax。tempMin 是風(fēng)扇開(kāi)始旋轉(zhuǎn)的溫度,tempMax 是紅色 LED 燈警告您已達(dá)到最高溫度時(shí)的溫度。例如,如果將 tempMin 設(shè)置為 30,將 tempMax 設(shè)置為 35,則風(fēng)扇將在 30°C 時(shí)開(kāi)始旋轉(zhuǎn),并在 35°C 時(shí)達(dá)到其最高速度。
  將溫度值存儲(chǔ)在 temp 變量中,然后使用一些 if() 函數(shù)來(lái)檢查溫度是否低于 tempMin,如果是,則讓風(fēng)扇關(guān)閉 (LOW)。下一個(gè) if() 是檢查溫度是否高于 minTemp 并低于 tempMax,如果是,則使用 map() 函數(shù)將溫度值從一個(gè)值重新映射到另一個(gè)值。在我們的例子中,fanSpeed 在 tempMin 的值為 32,在 tempMax 的值為 255。這些值用于通過(guò) PWM 和 analogWrite() 控制風(fēng)扇的速度。
  風(fēng)扇LCD 重新映射溫度,允許在 0 到 100% 范圍內(nèi)顯示風(fēng)扇速度,因此您可以說(shuō)風(fēng)扇的速度直接取決于 LM35 的溫度。當(dāng)溫度達(dá)到 tempMax 中設(shè)置的值時(shí),風(fēng)扇將處于其最大旋轉(zhuǎn)速度,并且 LCD 將顯示 FANS:100%,即使溫度可能會(huì)升高到 tempMax 以上。

1次

版權(quán)與免責(zé)聲明

凡本網(wǎng)注明“出處:維庫(kù)電子市場(chǎng)網(wǎng)”的所有作品,版權(quán)均屬于維庫(kù)電子市場(chǎng)網(wǎng),轉(zhuǎn)載請(qǐng)必須注明維庫(kù)電子市場(chǎng)網(wǎng),http://www.udpf.com.cn,違反者本網(wǎng)將追究相關(guān)法律責(zé)任。

本網(wǎng)轉(zhuǎn)載并注明自其它出處的作品,目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點(diǎn)或證實(shí)其內(nèi)容的真實(shí)性,不承擔(dān)此類(lèi)作品侵權(quán)行為的直接責(zé)任及連帶責(zé)任。其他媒體、網(wǎng)站或個(gè)人從本網(wǎng)轉(zhuǎn)載時(shí),必須保留本網(wǎng)注明的作品出處,并自負(fù)版權(quán)等法律責(zé)任。

如涉及作品內(nèi)容、版權(quán)等問(wèn)題,請(qǐng)?jiān)谧髌钒l(fā)表之日起一周內(nèi)與本網(wǎng)聯(lián)系,否則視為放棄相關(guān)權(quán)利。

廣告
OEM清單文件: OEM清單文件
*公司名:
*聯(lián)系人:
*手機(jī)號(hào)碼:
QQ:
有效期:

掃碼下載APP,
一鍵連接廣大的電子世界。

在線人工客服

買(mǎi)家服務(wù):
賣(mài)家服務(wù):
技術(shù)客服:

0571-85317607

網(wǎng)站技術(shù)支持

13606545031

客服在線時(shí)間周一至周五
9:00-17:30

關(guān)注官方微信號(hào),
第一時(shí)間獲取資訊。

建議反饋

聯(lián)系人:

聯(lián)系方式:

按住滑塊,拖拽到最右邊
>>
感謝您向阿庫(kù)提出的寶貴意見(jiàn),您的參與是維庫(kù)提升服務(wù)的動(dòng)力!意見(jiàn)一經(jīng)采納,將有感恩紅包奉上哦!