描述
技術規格
1.訊號傳輸型式: 類比 (Analog)
2.電壓範圍:3.0V ~ 5.5V。
3.測溫範圍:-40℃到150℃
4.敏感度:10mV/℃(輸出電壓與溫度成正比)
商品內容
- LM35線性溫度感測模組 1個
- RJ11 6P4C 25cm 信號線 1條
程式範例
在此範例配合S4A IO Board 做簡單實驗, 在超過30℃時由綠燈切換成紅燈警示
int analogPin = A3;//LM35接在A3
int readValue = 0;
float temperature = 0;
float temperatureF = 0;
int times = 0;
float Total_temperature = 0;
void setup()
{
Serial.begin(9600);//設置baud rate
pinMode (10, OUTPUT);//紅色LED接在d10
pinMode (11, OUTPUT);//綠色LED接在d11
}
void loop()
{
readValue = analogRead(analogPin);
//Serial.println(readValue);
temperature = (readValue * 0.0049);
temperature = temperature * 100;
temperatureF = (temperature * 1.8) + 32;
Total_temperature = Total_temperature + temperature;
times = times + 1;
if(times == 10)
{
temperature = Total_temperature / times;
Serial.print(“Temperature: “);
Serial.print(temperature);
Serial.print(“C “);
Serial.print(temperatureF);
Serial.println(“F”);
if (temperature <= 30)
{
digitalWrite (10, LOW);
digitalWrite (11, HIGH);
}
if (temperature > 30)
{
digitalWrite (10, HIGH);
digitalWrite (11, LOW);
}
times = 0;
Total_temperature = 0;
}
delay(100);
}