Skip to content

Instantly share code, notes, and snippets.

@iotguider
Created July 25, 2017 15:31
Show Gist options
  • Save iotguider/685f4d9b2360128ba915e55639b09d7b to your computer and use it in GitHub Desktop.
Save iotguider/685f4d9b2360128ba915e55639b09d7b to your computer and use it in GitHub Desktop.
Code for Temperature Sensor in Arduino
int tempPin = A0; //Number of Temperature Sensor Pin
int analoginput; //Variable to store Analog Input Value
float temp; //Variable to store Temperature in C
void setup()
{
// Begin the Serial Monitor at 9600 Baud
Serial.begin(9600);
}
void loop()
{
//Get the Analog Input and store in analoginput variable
analoginput = analogRead(tempPin);
//Convert the Analog Input value to Temperature in C
temp = (5.0 * analoginput * 100.0) / 1024;
//Print the Temperature in Serial Monitor
Serial.println(temp);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment