fans buzzer

This commit is contained in:
2025-02-07 15:02:44 +08:00
parent 994cc56f3e
commit a63486a9e0

View File

@ -11,6 +11,7 @@
#include <Ticker.h>
#include <Preferences.h> // 用于存储非易失性数据
Preferences preferences;
// 灯泡计时器
@ -46,6 +47,14 @@ BH1750 bh1750_b;
#define TJC_RX_Pin 41
// 风扇控制引脚
#define FAN_PIN1 15
#define FAN_PIN2 16
// 蜂鸣器引脚
#define BUZZER_PIN 17
// HTML 页面内容
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE html>
@ -317,6 +326,27 @@ void TJC_Show(void)
}
// 风扇控制
void FansControl(void) {
if (sensor.getTempC() > 25) {
digitalWrite(FAN_PIN1, HIGH);
digitalWrite(FAN_PIN2, HIGH);
} else {
digitalWrite(FAN_PIN1, LOW);
digitalWrite(FAN_PIN2, LOW);
}
}
// 蜂鸣器报警
void Buzzer(void) {
if (sensor.getTempC() > 50) {
tone(BUZZER_PIN, 1000, 1000);
} else {
noTone(BUZZER_PIN);
}
}
void setup(void)
{