LM35温度传感器简介
LM35 是由National Semiconductor 所生产的温度传感器,其输出电压为摄氏温标。LM35是一种得到广泛使用的温度传感器。
由于它采用内部补偿,所以输出可以从0℃开始。LM35有多种不同封装型式。在常温下,LM35 不需要额外的校准处理即可达到 ±1/4℃的准确率。
LM35温度传感器的输出电压和摄氏度温度呈线性关系,0℃时输出0V,每升高1℃,输出电压增加10mV。
获取温度值
根据这个公式可知,若想得到正确的温度数值,我们需要在获取温度传感器的数值后面乘以0.488,最终可得到正确的室温。
规格参数
LM35温度传感器的使用
实验一:获取室温
项目要求:
通过串口监视器得到所属环境的温度数值。
注意:光敏电阻为模拟输入器件,对应的端口为:A0~A5。
电路搭建
参考程序
复制代码
1
2
3
4
5
6
7
8
9
10
11const 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); }
实验结果
从串口监视器中得到对应的室温。
实验二:温度报警器
项目要求:
1、当温度大于30℃时,红灯亮且蜂鸣器响起;
2、当温度小于或者等于30℃时,绿灯亮。
注意:光敏电阻为模拟输入器件,对应的端口为:A0~A5。
电路搭建
略。
参考程序
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34const 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); } }
实验结果
得到项目结果。
最后
以上就是孝顺宝贝最近收集整理的关于Arduino Uno 实验6——LM35温度传感器的全部内容,更多相关Arduino内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复