Created
July 25, 2017 15:31
-
-
Save iotguider/685f4d9b2360128ba915e55639b09d7b to your computer and use it in GitHub Desktop.
Code for Temperature Sensor in Arduino
This file contains 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
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