1
無法測量arduino中溫度傳感器的溫度, 其給出錯誤的溫度=溫度= 499.51 * c。即時連接溫度傳感器到Arduino uno套件。我需要像35的溫度值無法用arduiono套件中的溫度傳感器測量溫度值
int val;
int tempPin = 1;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = (val/1024.0) * 5000;
float cel = mv/10;
float farh = (cel * 9)/5 + 32;
Serial.print("TEMPRATURE = ");
Serial.print(cel);
Serial.print("*C");
Serial.println();
delay(1000);
/* uncomment this to get temperature in farenhite
Serial.print("TEMPRATURE = ");
Serial.print(farh);
Serial.print("*F");
Serial.println();
*/
}