วันจันทร์ที่ 23 กรกฎาคม พ.ศ. 2561

Interfacing Thermistor with Arduino to Measure and Display Temperature on LCD



#include <math.h>
#include "LiquidCrystal.h"
LiquidCrystal lcd(44,46,40,52,50,48);
float A = 1.009249522e-03, B = 2.378405444e-04, C = 2.019202697e-07;
float T,logRt,Tf,Tc;
float Thermistor(int Vo) {
 logRt = log(10000.0*((1024.0/Vo-1))); 
 T = (1.0 / (A + B*logRt + C*logRt*logRt*logRt));  // We get the temperature value in Kelvin from this Stein-Hart equation
 Tc = T - 273.15;                     // Convert Kelvin to Celcius
 Tf = (Tc * 1.8) + 32.0;              // Convert Kelvin to Fahrenheit
 return T;
}
void setup(){
 lcd.begin(16,2);
 lcd.clear();
}
void loop() 
{
 lcd.setCursor(0,0);
  lcd.print("Temp:");
  lcd.print((Thermistor(analogRead(0))));
  lcd.print("k ");
 
 lcd.setCursor(0,1);
  lcd.print((Tc));
  lcd.print(" C ;");
 lcd.setCursor(9,1);
  lcd.print((Tf));
  lcd.print(" F");
 delay(800);
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

งานชิ้นที่ 1

องค์ประกอบหน้าที่ต่างๆของโรงงาน โดยแบ่งหน้าที่ตามความเหมาะสมและความถนัดบริหารโดยมีหัวหน้าใหญ่เป็นผู้จัดตำแหน่งหน้าที่ ...