עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

בקשת עזרה בקוד לטמפרטורה

Featured Replies

פורסם

שלום לכם,

יש לי 2 שאלות אליכם

אני משתמש בחיישן טמפרטורה DHT11 לקחתיח את ההקוד לבדיקת החיישן לפי מה שמופיע בדוגמא, ולקחתי קוד לביצוע טרמוסטט כלל בידקת שינוי מצב.

1. קוד לבדיקת החשיין


int chk = DHT11.read(DHT11PIN); // read to check the sensor
switch (chk)
{
case 0: Serial.println("OK"); break;
case -1: Serial.println("Checksum error"); break;
case -2: Serial.println("Time out error"); break;
default: Serial.println("Unknown error"); break;
}

אם אני מעוניין ברגע שזה מחזיר שגיאה שיבצע בדיקה חוזרת של החיישן אני פשוט צריך להוריד את ה BREAK בסוף השורה?

אם לא, איך אלי לעשות זאת ?

2. קוד לטרמוסטט עבור מצב חום ומצב קור.


// ---- turn on or off damper in function of temperature in cold mode
if (mode == 1){ // check if the mode is in cold mode
if (temp >= DesirableTemp)
{
flag = 1;
if (flag =! prev_flag) {
digitalWrite(damper, HIGH);
}
}
else if (temp <= DesirableTemp)
{
flag = 0;
if (flag =! prev_flag) {
digitalWrite(damper, LOW);
}
}
prev_flag = flag;
}
// ---- end of temperature in cold mode

// ---- turn on or off damper in function of temperature in hot mode
if (mode == 0){ // check if the mode is in hot mode
if (temp <= DesirableTemp)
{
flag = 1;
if (flag =! prev_flag) {
digitalWrite(damper, HIGH);
}
}
else if (temp >= DesirableTemp)
{
flag = 0;
if (flag =! prev_flag) {
digitalWrite(damper, LOW);
}
}
prev_flag = flag;
}
// ---- end of temperature in hot mode

האם יש דרך לאחד את 2 הקודים בלי ביצוע בדיקת מצב ולא משנה אם זה על חום או על קור פשוט יבצע את הפעולה ?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.