Created
October 25, 2015 15:07
-
-
Save michaelsarduino/75fdc7af4c6989f4a278 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
long readTemp() { | |
long result; | |
// Read temperature sensor against 1.1V reference | |
ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); | |
delay(2); // Wait for Vref to settle | |
ADCSRA |= _BV(ADSC); // Convert | |
while (bit_is_set(ADCSRA,ADSC)); | |
result = ADCL; | |
result |= ADCH<<8; | |
result = (result - 125) * 1075; | |
return result; | |
} | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
Serial.println( readTemp(), DEC ); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment