Created
September 19, 2016 08:12
-
-
Save openopen114/cd784858b283b9d79a9163946385b9b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Hugo Zeng | |
//2016/09/19 | |
//[email protected] | |
int ledPin = 13; | |
void setup() { | |
pinMode(ledPin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
int LM35value; //LM35 value form A0 | |
double LM35Temp; //temp = value * (5/10.24) | |
LM35value = analogRead(0); | |
LM35Temp = (double) LM35value * (5/10.24); | |
//Temp >25, LED Lights up | |
if(LM35Temp>25){ | |
digitalWrite(ledPin,HIGH); | |
delay(2000); | |
}else{ | |
digitalWrite(ledPin, LOW); | |
delay(2000); | |
} | |
//console temp every 3 second; | |
Serial.print("temperature: "); | |
Serial.print(LM35Temp); | |
Serial.println("C"); | |
delay(3000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment