Developing Communities Be Good Do Good
Chandler 85248
chandan
/*
modified by chandan
Grove - Temprature Sensor demo v1.0* This sensor detects the enviroment temprature,* Connect the signal of this sensor to A0, use the * Serial monitor to get the result.* By: http://www.seeedstudio.com*/
#include <math.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int colorR = 0;
const int colorG = 255;
const int colorB = 0;
int a;float temperature;int B=3975; //B value of the thermistorfloat resistance;
void setup(){
Serial.begin(9600); // set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB); // Print a message to the LCD.
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Greetings from ");
lcd.setCursor(0,1);
lcd.print("CSL!");
delay(10000);
}
void loop(){
a=analogRead(2);
resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;
temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
//convert to temperature via datasheet ;
delay(1000);
Serial.print("Current temperature is ");
Serial.println(temperature);
if(temperature > 25){
lcd.setRGB(255,0,0);
lcd.clear(); lcd.setCursor(0,0);
lcd.print("temperature");
lcd.setCursor(0,1);
lcd.print("Please use fan!");
delay(500);
} else if(temperature < 23){
lcd.setRGB(0,255,0);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Low Temperature: temperature!");
lcd.setCursor(0,1);
lcd.print("temperature");
delay(1000);
}
}
Copyright 2019 Chandan Shamala Library. All rights reserved.
Chandler 85248
chandan