ความรู้แน่น ฟรีสำหรับชุมชน ArduinoAll ที่นี่เท่านั้น

ฟรีและดีที่สุด คอร์สอบรม Arduino + NodeMCU
ทำเพื่อแบ่งปัน ห้ามนำไปจำหน่าย หรือเก็บเงินค่าเรียน
  !!!


  


AllNewStep รับประกันคุณภาพทุกชิ้น วันจันทร์-ศุกร์แจ้งชำระสินค้าก่อน 14.00 จัดส่งทันทีวันนี้ค่ะ

กรุงเทพ /ภาคกลาง ได้พรุ่งนี้


*** สินค้าทุกชิ้น ถ้าสามารถทำรายการสั่งซื้อได้ แสดงว่ามีครบทุกรายการค่ะ *** 

พิมพ์ค้นหาบทความ หัวข้อกระทู้ และสินค้าในเว็บ AllNewStep ได้ที่นี่
QUOTE 

ช่วยผมทำโปรเจคหน่อยครับ

Jommych Jomyothakal

คือผมจะใช้ DHT sensor รับค่าอุณหภูมิและความชื้นมา จากนั้นผมจะใช้ buzzer เตือน โดยมีเงื่อนไข เช่น

ถ้าอุณหภูมิ ต่ำกว่า 25 และ ความชื้นต่ำกว่า 60 ให้ดัง 1 วิ ดับ 1 วิ ทำวนไป

ถ้าอุณภูมิมมากกว่า 35 และ ความชื้นมากกว่า 80 ให้ดัง 5 วิ ดับ 1 วิ ทำวนไป

ผมควรทำอย่าไรดีครับ

 

QUOTE 
ความคิดเห็นที่ #1
เจ้าของร้าน

ทำได้ไม่ยากครับ มีตัวอย่างโค้ดในคอร์สสอน Arduino Starter ที่หน้าเว็บครับ

QUOTE 
ความคิดเห็นที่ #2
Jommych Jomyothakal

เบื้องต้นได้ทำตามที่วีดีโอสอนแล้วครับ แต่ติดปัญหาคือ buzzer ดังตลอดไม่มีเว้นช่วงเลยครับ

ทั้งที่สั่งให้ LOW แล้ว delay ไว้ครับ

โค้ด :

#include<Wire.h>

#include<DHT.h>

#define DHTPIN 2                                    

#define DHTTYPE DHT11                               

DHT dht(DHTPIN, DHTTYPE);

#include<LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

int buzzer = 13;

 

void setup()

{

  dht.begin();

  lcd.begin();

  lcd.backlight();

  pinMode(buzzer, OUTPUT);

}

 

void loop()

{

  lcd.setCursor(1,0);

  lcd.print("Heat Stroke Meter");

  lcd.setCursor(0,1);

  lcd.print("RISK : ");

  lcd.setCursor(0,2);

  lcd.print("--------------------");

  

  float h = dht.readHumidity();

  float t = dht.readTemperature();

 

  if(isnan(t)||isnan(h)){

    lcd.println("Failed to read from DHT");

  }

    

   //lcd.clear();

    lcd.setCursor(0,3);

    lcd.print("H:");

    lcd.print(h);

    lcd.print("%");

    lcd.setCursor(8,3);

    lcd.print("T:");

    lcd.print(t);

    lcd.print("C");

    delay(500);

    

  if(((t<=27)&&(h<=40))){

    //lcd.clear();

    lcd.setCursor(7,1);

    lcd.println("Not Hot");

    delay(500);}

    if((t<=27)&&((h>=55)&&(h<=59))){

    digitalWrite(buzzer, HIGH);

  delay(1000);

  digitalWrite(buzzer, LOW);

  delay(1000);

    }

    

  if(((t>=27)&&((h>=40)&&(h<=100))) && ((t>=28)&&((h>=40)&&(h<=89))) && ((t>=29)&&((h>=40)&&(h<=74))) && 

  ((t>=30)&&((h>=40)&&(h<=59))) && ((t>=31)&&((h>=40)&&(h<=49)))){

    //lcd.clear();

    lcd.setCursor(7,1);

    lcd.println("Normal"); 

    delay(500);}

    while( ((t>=27)&&(t<=32)) &&((h>=60)&&(h<=64)) ){

    digitalWrite(buzzer, HIGH);

  delay(1000);

  digitalWrite(buzzer, LOW);

  delay(2000);

    }

    

  if(((t>=28)&&((h>=90)&&(h<=100))) && ((t>=29)&&((h>=75)&&(h<=100))) && ((t>=30)&&((h>=60)&&(h<=89))) && 

  ((t>=31)&&((h>=50)&&(h<=79))) && ((t>=32)&&((h>=40)&&(h<=69))) && ((t>=33)&&((h>=40)&&(h<=59))) && 

  ((t>=34)&&((h>=40)&&(h<=54))) && ((t>=36)&&((h>=40)&&(h<=49)))){

   // lcd.clear();

    lcd.setCursor(7,1);

    lcd.println("Caution");

    delay(500);}

     while( ((t>=33)&&(t<=40)) &&((h>=65)&&(h<=70)) ){

    digitalWrite(buzzer, HIGH);

  delay(1000);

  digitalWrite(buzzer, LOW);

  delay(3000);

    }

    

  if(((t>=30)&&((h>=90)&&(h<=100))) && ((t>=31)&&((h>=80)&&(h<=100))) && ((t>=32)&&((h>=70)&&(h<=99))) && 

  ((t>=33)&&((h>=60)&&(h<=89))) && ((t>=34)&&((h>=55)&&(h<=79))) && ((t>=36)&&((h>=50)&&(h<=74))) && 

  ((t>=37)&&((h>=40)&&(h<=64))) && ((t>=38)&&((h>=40)&&(h<=59))) && ((t>=39)&&((h>=40)&&(h<=54))) && 

  ((t>=40)&&((h>=40)&&(h<=44))) && ((t>=41)&&(h>=40))){

   // lcd.clear();

    lcd.setCursor(7,1);

    lcd.println("Danger");

    delay(500);}

    while( ((t>=41)&&(t<=54)) &&((h>=70)&&(h<=75)) ){

    digitalWrite(buzzer, HIGH);

  delay(1000);

  digitalWrite(buzzer, LOW);

  delay(4000);

    }

    

  if(((t>=32)&&(h<=100)) && ((t>=33)&&(h>=90)) && ((t>=34)&&(h>=90)) && ((t>=36)&&(h>=75)) && 

  ((t>=37)&&(h>=65)) && ((t>=38)&&(h>=60)) && ((t>=39)&&(h>=55)) && ((t>=40)&&(h>=50)) && ((t>=41)&&(h>=45)) &&

  ((t>=42)&&(h>=40))) {

   // lcd.clear();

    lcd.setCursor(7,1);

    lcd.println("HAZARD!!!");

    delay(500);}

    while(((t>54)&&(h>75))) {

    digitalWrite(buzzer, HIGH);

  delay(1000);

  digitalWrite(buzzer, LOW);

  delay(5000);

    }

}

QUOTE 
ความคิดเห็นที่ #3
เจ้าของร้าน

ต้องทดสอบทีละจุด ลองเปลี่ยน buzzer เป็นตำแหน่งขาอื่น หรือทดลองเฉพาะ buzzer ครับ

แสดงความคิดเห็นที่ 1-3 จากทั้งหมด 3 ความคิดเห็น
ขาย ARDUINO
คุณภาพ อันดับ 1

ได้รับรางวัลร้านยอดเยี่ยม
ตั้งแต่ปี 2558
ขาย Arduino
วีดีโอสอน Arduino

สอน esp8266

สอน Arduino IoT
สอน Arduino แบบเร็ว

สอน NodeMCU

อุปกรณ์ Arduino

MEMBER ZONE

พูดคุย-สอบถาม