Skip to content

Commit

Permalink
Added TMP36 simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
tigoe committed Aug 16, 2013
1 parent 49d1fab commit 2d40831
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions TMP36/TMP36.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
TMP36 temperature sensor
Reads an analog input on pin 0, prints the result to the serial monitor
*/

void setup() {
Serial.begin(9600);
}

void loop() {
// read the value from the sensor:
int sensorValue = analogRead(A0);
// convert the reading to millivolts:
float voltage = sensorValue * (5.0/ 1024.0);
// convert the millivolts to temperature celsius:
float temperature = (voltage - 0.5)/0.01;
// print the temperature:
Serial.println(temperature);
}





0 comments on commit 2d40831

Please sign in to comment.