火焰传感器实验
实验目的
检测到火源报警
理论学习
火焰传感可以探测火源、热源。外籍红外光越强,数值越小,红外光越弱,数值越大
原理图
代码编写
#define adpin A0
#define buzzer 2
int adbuffer = 0;
void setup() {
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop() {
adbuffer = analogRead(adpin);
Serial.print("ad = ");
Serial.println(adbuffer);
if (adbuffer > 20) {
digitalWrite(buzzer, HIGH);
}
else {
digitalWrite(buzzer, LOW);
}
delay(500);
}