[Zero-knowledge ESP8266 tutorial] Quick Start 12- Making a flame alarm
[Copy link]
In the following sharing, we will add some new electronic elements, which are all applicable to the Zero Knowledge Development Board. The addition of these electronic elements is to facilitate our deeper understanding of the electronic world, and more importantly, to enable us to clearly understand the functions and effects of each component when we are doing projects in the future. By combining these simple elements, you can complete a small project, similar to the production of the buzzer model in the previous sharing. If you are interested, you can directly follow the official website of Zero Knowledge Lab, share your electronic works, learn together, and make progress together.
In this work, we use a new element - flame alarm.
The flame alarm mainly uses the characteristic that infrared triodes are very sensitive to flames. When there is a flame, the infrared receiving tube will convert the brightness of the flame into a high or low level change, thereby detecting the occurrence of a flame. Next, we will make a simple flame alarm. When a flame occurs, our LED light will light up to remind you of the occurrence of a flame.
1. Tools and materials
Computer, Windows system
Zero-knowledge ESP8266 development board
micro-usb cable
LED lamp 1
220Ω resistor 1
Flame sensor 1
10kΩ resistor 1
Breadboard + several jumpers
2. Hardware Connection
3. Method steps
1. Open the Zero Knowledge Lab software development tool, then create a new project and enter the following code:
/**
* 文件: 火焰报警器.ino
* 时间: 2018/06/26 15:23
* 说明:
**/
int port = A0;//连接火焰传感器
int led = 0;//连接LED报警的脚
int value = 0;//测量的模拟数值
// the setup routine runs once when you press reset:
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);//初始化LED灯
Serial.begin(9600);//设置打印的波特率
}
// the loop routine runs over and over again forever:
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(port);
Serial.println(value);//打印出来便于调试
if(value > 50)//这个值要根据实际情况进行调整到最佳,根据串口打印得到的数据来调整
{
digitalWrite(led, LOW);//打开LED,进行报警
}
else{
digitalWrite(led, HIGH);//关闭led
}
delay(500);//延时一会儿,这里是为了串口打印便于观察,实际的时候要把这个延时去掉或者延时很小的一段时间
}
2. Follow the previous method to [Verify] first, and then [Upload] to the development board.
IV. Results display
After the above steps are successfully completed, we can see the expected results. Here, when we do not have the flame test conditions, we can use the infrared remote control to simulate it. When a button of the infrared remote control is pressed, an infrared signal is sent. When the remote control button is pressed towards the flame sensor, the LED light is on, and the serial port tool can see that the simulated value is relatively large. In the real scene, you can use a lighter light to verify it, and the value also has obvious changes!
|