ข้ามไปที่เนื้อหาหลัก

ส่งงานครั้งที่ 4

Temperature Controlled AC Home Appliances using Arduino and Thermistor

อุปกรณ์

  • Arduino UNO
  • Relay (5v)
  • 16*2 LCD display
  • Light Bulb (CFL)
  • NTC thermistor 10k
  • Connecting wires
  • Resistors (1k and 10k ohms)
  • Potentiometer (10k)
Circuit Diagram
Code

#include <math.h> //ใช้ฟังก์ชั่นทางคณิตศาสตร์
#include "LiquidCrystal.h" //ใช้จอLCD
#define RELAY 8 //สร้างRelay=8   
LiquidCrystal lcd(6,7,5,4,3,2);
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));  // สูตรการคำนวณเคลวิน
 Tc = T - 273.15;                 // เปลี่ยนเป็นองศาเซลเซียส
 Tf = (T * 1.8) + 32.0;           // เปลี่ยนเป็นองศาฟาเรนไฮ
 return T;
}
void setup() {
 lcd.begin(16,2);
 lcd.clear();
pinMode(RELAY, OUTPUT); 
}
void loop() {  
  lcd.setCursor(0,0); //ตั้งตำแหน่งไปที่0x0
  lcd.print("Temperature:"); //ให้พิมพ์Temperature
  lcd.print(int(Thermistor(analogRead(0))));
  lcd.print("C ");
  delay(500);  // รอครึ่งวิเพื่อให้อ่านค่าอีกครั้ง
if (Tc > 28) digitalWrite(RELAY, HIGH),lcd.setCursor(0,1),lcd.print("Light status:ON "),delay(500);
elseif(Tc<28)digitalWrite(RELAY,LOW),lcd.setCursor(0,1),lcd.print("Light status:OFF"),delay(500);  
}

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

ส่งงานครั้งที่ 16

Smoke Detector Using MQ2 อุปกรณ์ Arduino UNO Smoke Detector Arduino Shield (Self Designed) Power Supply Smoke Sensor (MQ2) Resistors (10K and 1K) Buzzer 16x2 LCD 10k POT LED LM358 Burg strips Diagram Code #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #define buzzer 9 #define sensor A0   #define load_Res 10   #define air_factor 9.83                                                   float SmokeCurve[3] ={2.3,0.53,-0.44};    // (x, y, slope) x,y พิกัดของจุดหนึ่งและความลาดชันระหว่างสองจุด                                                                                     ...

ส่งงานครั้งที่ 9

Gyro Sensor Interfacing Gyro Sensor  คือเซ็นเซอร์ที่มีไว้สำหรับตรวจจับลักษณะการหมุน โ ดยเป็นการตรวจจับแบบ  3  แกน  (3-Axes) อุปกรณ์ Arduino Uno MPU-6050 10K POT Jumper wire Breadboard USB cable Power supply Diagram Code #include<LiquidCrystal.h> //ประกาศเมื่อใช้จอ LiquidCrystal lcd(8,9,10,11,12,13); //ขาที่ต่อจอ #include <Wire.h> #include <MPU6050.h> #define period 10000 MPU6050 mpu; int count=0; char okFlag=0; byte degree[8] = {   0b00000,   0b00110,   0b01111,   0b00110,   0b00000,   0b00000,   0b00000,   0b00000 }; void setup()  {   lcd.begin(16,2);   lcd.createChar(0, degree);   Serial.begin(9600);   Serial.println("Initialize MPU6050");   while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))   {     lcd.clear();     lcd.print("Device not Found"...

ส่งงานครั้งที่ 19

Door Alarm อุปกรณ์ Breadboard Ultrasonic Sensor Buzzer Arduino Mega (any model) Jumper Wires USB cable for Arduino or 12v, 1A adapter. Diagram Code #include <NewPing.h> #define TRIGGER_PIN  12  // กำหนดให้ขา 12 เป็นTRIGGER #define ECHO_PIN     11  // กำหนดให้ขา 11 เป็นECHO #define MAX_DISTANCE 500 // ค่าระยะห่างที่มากที่สุด NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPingตั้งค่าระยะห่าง unsigned int pingSpeed = 50; // ความถี่ในการส่งข้อมูล unsigned long pingTimer; int flag = 0; // รอpingครั้งต่อไป void setup() {   Serial.begin(115200); // เปิด serial monitor ที่ 115200   pingTimer = millis();   pinMode(10, OUTPUT);   // Start now. } void loop() {   if (millis() >= pingTimer) {   // pingSpeed จากครั้งล่าสุดถึงอีก ping     pingTimer += pingSpeed;      // ตั้งเวลาpingครั้งต่อไป     sonar.ping_timer(echoCheck); // ส่งค่าpingออกเรีย...