|
|

楼主 |
发表于 2014-7-12 14:08:34
|
显示全部楼层
int tempPin = 0;
int LEDPin = 13;
void setup()
{
pinMode(LEDPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
//Read voltage from temp the temp sensor
int reading = analogRead(tempPin);
float voltage = reading*5.0;
voltage = voltage/1024.0;
//transfer voltage to temp Celsius
float tempC = (voltage - 0.5)*100;
//if tempC > 35 , light LED up
if(tempC >= 35)
{
digitalWrite(LEDPin,HIGH);
}
else
{
digitalWrite(LEDPin,LOW);
}
//Serial monitor for debug
Serial.println(tempC);
delay(500);//delay 0.5s
}
错误提示 avrdude: stk500_getsync(): not in sync: resp=0x00 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|