 This is a flame sensor. When the flame burns, it creates a flame, it creates strong bright light, and it creates obviously heat. But one thing we don't see that it does create is some infrared light, which is also known as IR. Inside this black housing right here, we have an IR sensor which will go and detect that IR light coming off of the flame. Using that, we're able to detect whether there is a flame or whether there is no flame. The nice thing about this sensor is it has two different pins. It has a digital out and an analog out, allowing you to use it for different cases. Our ideal use case for this would be if I'm building something next to some fuel lines in the house or next to somewhere where we store gas, and you want to make sure that this does not touch anything that's very combustible and can just make a big explosion and burn everything to the ground. So you would use this as a failsafe. So this would be on a piece of electronic that you're building, and you would say if this ever detects a flame, if it ever says, oh no, something happens, it ever gets triggered, this would shut down everything. So if you're sending electricity to your electronic board and the board shorts and it starts to create a fire, as long as electricity is being pushed into the board, it's continuing to spark and making the fire even bigger. This would get triggered when it senses a flame and then it would shut down the electricity going to that electronic board and now you reduce your fire or you stop it. There's not many situations where this would be like your primary sensor where you're using this to walk around and detect flame because you can just use your eyes or your smell or feel and you know that there's a flame and fire in front of you. So this would be used mostly in places where you don't want a human to be in or you can't have a human checking 24-7. This would be kind of like your little security guard, your protection, your smoke alarm for your electronics. So as I said earlier, we're going to be using the digital pin and not the analog pin and the ones in the middle there are G and plus meaning ground and power. I'm going to be using a little breadboard just because it's easier. So we're going to go and plug in our power cable into the plus sign and we're going to grab our blue cable and use that for the ground and then our yellow cable will be on the digital out because we don't want to use analog. Now that you have those three, grab your Arduino and go ahead and plug in your yellow cable into number four on the board, your red cable into the five volt and your blue cable into the ground. One thing I should note is ideally you would have the power source and Arduino and all this separate from your main electronics board or whatever project you're working on because if that thing burns in shorts, it's not going to be able to turn itself off. So you need to have this on the side. So let's say we had one big project here and then we had this little setup on the side and the power went from a power outlet to our little project to our main project. This would be in the middle saying, hey, stop passing electricity to the main project because there's a fire. This would be like your little safety switch in the middle of the circuit. You wouldn't mount this onto the main board because then if the main board is on fire and not working, then this isn't going to work and it's never going to shut itself off and you're going to have a big fire. Things are going to happen, explosions, whatever. I don't know. Plug your Arduino into your computer and let's write some code. So the sensor is actually really simple. There's not much to it. We're just going to do a couple little things. The first thing is we're going to declare a variable and we can call it sensor and we put that into pin number four. Then we can go under that and we'll make a another integer and we'll call it fire under that in your setup. Let's go ahead and activate the console just because we're not going to like turn on an LED or anything like that. We'll just display some text and say, hey, there's a fire or you're good to go. You're safe. We'll go and put this on the same band as always, 9600. And then under that, we're going to go and activate our digital pin that we're using. We're going to call it sensor and then we're going to tell it it's an input pin receiving signal or receiving something from this pin, which is plugged into our sensor. Then we're going to go down here and call our fire variable and then we're going to use digital read to check our sensor and see if we have a fire. So every time this loops, it's going to check the sensor and read if anything's coming from it. If anything's coming from the sensor, like a one, then we're going to have a fire. We're going to have a problem and we're going to have to do something about it. Under that, let's go make a little if statement and do exactly what we just said. So if fire is ever equal to one, then we have a problem. And then here we can go and say something like serial dot print line. And then under that we could do an L statement and just say no fire detected. So now it's going to go, it's going to read the loop every time. Let's go and put a little delay so it only checks every, let's say one second probably would work fine. So now every one second is going to check if the sensor is returning a number one. Then if we ever hit anything other than one, it's going to say no fire detected. If we hit one, it's going to say fire emergency and tell us that there's a problem. Let's go compile it and upload it to our Arduino. Make sure tools board, they are on the right board and port. We have an error here. Let's see what the error is. All right, we're on the wrong port. So just go tools, port. You can go in tools again and open up your serial monitor, which is what this little screen is. And in your serial monitor, when you upload your code, you should start seeing every second. It's going to print something like no fire detected. There you go. And it's going to keep printing that every second. Now I'm going to take a lighter here. I'm going to light the lighter next to the sensor and it should freak out. Right away instant fire emergency, fire emergency, fire emergency and I can pull this away and it should go pretty far. Right now it's set to what is that about three inches away, two inches away. If you go on the blue piece here on the sensor, there's a little knob. You can turn that up and down to change the sensitivity. I'd say you want it pretty sensitive, better safe than sorry. Worst case it turns everything off. You just go and turn it back on. But the other situation would be if there's a fire and it doesn't detect it, that can be pretty dangerous. So better safe than sorry. Let's turn on the lighter again. You can see that activates the fire emergency and the second I let go, it goes back to no fire detected. If you guys enjoyed this short video, please do give it a like and consider subscribing. A huge amount of my viewers are not subscribed to my channel. I think it was like 80% or something like that. So it really helped me a lot. This channel isn't monetized. All these videos I make are purely out of the love for this stuff. And I'd love to be able to monetize it so I can continue doing it and continue affording all the sensors, the boards and building more projects in the future. Thanks so much for being here and I'll see you guys in the next one.