Devices & Components
Arduino Uno Rev3
Temperature Sensor
Software & Tools
Arduino IDE
Project description
Code
Temperature computing and monitoring
arduino
1const int sensor=A5; // Assigning analog pin A5 to variable 'sensor' 2 3float tempc; //variable to store temperature in degree Celsius 4 5float tempf; //variable to store temperature in Fahreinheit 6 7float vout; //temporary variable to hold sensor reading 8 9void setup() { 10 11pinMode(sensor,INPUT); // Configuring sensor pin as input 12 13Serial.begin(9600); 14 15} 16 17void loop() { 18 19vout=analogRead(sensor); //Reading the value from sensor 20 21vout=(vout*500)/1023; 22 23tempc=vout; // Storing value in Degree Celsius 24 25tempf=(vout*1.8)+32; // Converting to Fahrenheit 26 27Serial.print("in DegreeC="); 28 29Serial.print("\ "); 30 31Serial.print(tempc); 32 33Serial.print(" "); 34 35Serial.print("in Fahrenheit="); 36 37Serial.print("\ "); 38 39Serial.print(tempf); 40 41Serial.println(); 42 43delay(500); //Delay of 1 second for ease of viewing }
Temperature computing and monitoring
arduino
1const int sensor=A5; // Assigning analog pin A5 to variable 'sensor' 2 3float 4 tempc; //variable to store temperature in degree Celsius 5 6float tempf; //variable 7 to store temperature in Fahreinheit 8 9float vout; //temporary variable to hold 10 sensor reading 11 12void setup() { 13 14pinMode(sensor,INPUT); // Configuring 15 sensor pin as input 16 17Serial.begin(9600); 18 19} 20 21void loop() { 22 23vout=analogRead(sensor); 24 //Reading the value from sensor 25 26vout=(vout*500)/1023; 27 28tempc=vout; 29 // Storing value in Degree Celsius 30 31tempf=(vout*1.8)+32; // Converting to 32 Fahrenheit 33 34Serial.print("in DegreeC="); 35 36Serial.print("\ "); 37 38Serial.print(tempc); 39 40Serial.print(" 41 "); 42 43Serial.print("in Fahrenheit="); 44 45Serial.print("\ "); 46 47Serial.print(tempf); 48 49Serial.println(); 50 51delay(500); 52 //Delay of 1 second for ease of viewing }
Downloadable files
Temperature computing and monitoring
Temperature computing and monitoring
Comments
Only logged in users can leave comments