IOT Experiment -5
READ TEMPERATURE AND DISPLAY ON SERIAL MONITOR USING ARDUINO UNO IN DEGREE CELCUIS AND FAHREINHEIT
SORCE CODE:
const int sensor=A5;
float tempc;
float tempf;
float vout;
void setup(){
pinMode(sensor,INPUT);
Serial.begin(9600);
}
void loop(){
vout = analogRead(sensor);
vout=(vout *500)/1023;
tempc=vout;
tempf=(vout*1.8)+32;
Serial.print("in DegreeC=");
Serial.print("\t");
Serial.print(tempc);
Serial.print(" ");
Serial.print("in Fahrenheit=");
Serial.print("\t");
Serial.print(tempf);
Serial.println();
delay(500);
}
Comments
Post a Comment