Arduino Uno 实验6——LM35温度传感器
生活随笔
收集整理的這篇文章主要介紹了
Arduino Uno 实验6——LM35温度传感器
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
LM35溫度傳感器簡介
??LM35 是由National Semiconductor 所生產(chǎn)的溫度傳感器,其輸出電壓為攝氏溫標(biāo)。LM35是一種得到廣泛使用的溫度傳感器。
??由于它采用內(nèi)部補(bǔ)償,所以輸出可以從0℃開始。LM35有多種不同封裝型式。在常溫下,LM35 不需要額外的校準(zhǔn)處理即可達(dá)到 ±1/4℃的準(zhǔn)確率。
??LM35溫度傳感器的輸出電壓和攝氏度溫度呈線性關(guān)系,0℃時(shí)輸出0V,每升高1℃,輸出電壓增加10mV。
獲取溫度值
??根據(jù)這個(gè)公式可知,若想得到正確的溫度數(shù)值,我們需要在獲取溫度傳感器的數(shù)值后面乘以0.488,最終可得到正確的室溫。
規(guī)格參數(shù)
LM35溫度傳感器的使用
實(shí)驗(yàn)一:獲取室溫
項(xiàng)目要求:
??通過串口監(jiān)視器得到所屬環(huán)境的溫度數(shù)值。
注意:光敏電阻為模擬輸入器件,對應(yīng)的端口為:A0~A5。
電路搭建
參考程序
const int wenduPin = A0; void setup() {pinMode(wenduPin, INPUT);Serial.begin(9600); } void loop() {int wendu = analogRead(wenduPin)*0.488;Serial.print("wendu =");Serial.println(wendu); }實(shí)驗(yàn)結(jié)果
??從串口監(jiān)視器中得到對應(yīng)的室溫。
實(shí)驗(yàn)二:溫度報(bào)警器
項(xiàng)目要求:
??1、當(dāng)溫度大于30℃時(shí),紅燈亮且蜂鳴器響起;
??2、當(dāng)溫度小于或者等于30℃時(shí),綠燈亮。
注意:光敏電阻為模擬輸入器件,對應(yīng)的端口為:A0~A5。
電路搭建
略。
參考程序
const int redLedPin = 5; const int greenLedPin = 6; const int fmqPin = 9; const int wenduPin = A0; void setup() {// put your setup code here, to run once:pinMode(redLedPin, OUTPUT);pinMode(greenLedPin, OUTPUT);pinMode(fmqPin, OUTPUT);pinMode(wenduPin, INPUT);Serial.begin(9600); } void loop() {// put your main code here, to run repeatedly:int wendu = analogRead(wenduPin)*0.488;Serial.print("wendu =");Serial.println(wendu);if (wendu > 30) {digitalWrite(redLedPin, HIGH);digitalWrite(greenLedPin, LOW);for (int i = 0; i < 50; i++){digitalWrite(fmqPin, HIGH);delay(1);digitalWrite(fmqPin, LOW);delay(1);}}else {digitalWrite(redLedPin, LOW);digitalWrite(greenLedPin, HIGH);} }實(shí)驗(yàn)結(jié)果
??得到項(xiàng)目結(jié)果。
總結(jié)
以上是生活随笔為你收集整理的Arduino Uno 实验6——LM35温度传感器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言电流检测模块程序,C语言和MATL
- 下一篇: 【毕业设计】基于单片机的智能衣柜系统设计