Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int LMT87 = P1_7;
- int TMP37 = P1_6;
- float LMT87raw = 0;
- float LMT87mV = 0;
- float TMP37raw = 0;
- float TMP37mV = 0;
- double mult = 3.477;
- double LMT87tempC = 0;
- double TMP37tempC = 0;
- double diff;
- void setup()
- {
- Serial.begin(9600);
- }
- void loop() {
- // read data
- LMT87raw = analogRead(LMT87);
- TMP37raw = analogRead(TMP37);
- // calculate values
- TMP37mV = TMP37raw*mult;
- TMP37tempC = TMP37mV/20;
- LMT87mV = LMT87raw*mult;
- LMT87tempC = -0.01488*((5*LMT87mV)-13163);
- diff = TMP37tempC-LMT87tempC;
- // display results
- Serial.print(TMP37tempC);
- Serial.print(" ");
- Serial.print(LMT87tempC);
- Serial.print(" ");
- Serial.println(diff);
- // if the difference between the two is more than 2C, blink red. Else blink green.
- if (diff>=2){
- digitalWrite(RED_LED, HIGH);
- delay(300);
- digitalWrite(RED_LED, LOW);
- delay(300);
- }
- else{
- digitalWrite(GREEN_LED, HIGH);
- delay(300);
- digitalWrite(GREEN_LED, LOW);
- delay(300);
- }
- // stop reading when button2 is pressed
- if (digitalRead(PUSH2)==LOW) {
- Serial.println("end");
- Serial.end();
- while(true);
- }
- delay(1000); // delay in between reads for stability
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement