 Move in, beep, beep, beep, beep, beep, beep, move out. And that's what you use the sensor for. Quickly before I start this video, did you guys know that 80% of my viewers right now are not subscribed to my channel? 80% of the people who watch my videos out of the 1,200 subs that I have are not subscribed to this channel. Now imagine if you guys were, how many subs we'd have. A recurring theme in most of my videos has been that we're going over sensors, they don't actually touch things, but they just sense for things. Like we've had the sensor where it was two poles and when you put something in the middle, like a piece of plastic or a piece of metal, it's something that triggered because the laser in between wasn't going anymore. Take that, stick it in the middle, keep an eye on the values. They just went up like crazy. Look at that, 940, 930, all the way up there. Then we went over proximity sensors like an IR sensor, which checks for body heat. So it actually sees the heat in my body, the heat radiation, and when it moves from one side to another, it triggered that outdoor light that we had. If I swipe my hand in front of it, it turns on. Then we went over ultrasonic sensors that use the same technology that the bats have. They shoot these super high-frequency sounds. It bounces off of an object, regardless of if it's a human or not, or a live or not, reflects back, and then based off of that, we can figure out the distance of how long the sound was traveling in the air. Wait for it, it's gonna come into the shot. Look at that. If I put my phone out of the way, right away it goes to the wall instantly. Well, here's another addition to those types of videos. This is an object avoidance sensor. It uses very similar tech to the sensor where we had two poles that were sending an IR sensor between them, and when something blocked it, it freaked out and said, hey, something's in front of me. Very similar to that, except instead of putting it between two poles, it's shooting it out and expecting it to receive back. So if I just start shooting it out like this, nothing would happen. But if there was a wall here, let's say, and I'm backing up my car and this is all my car, it would start shooting the IR light onto my hand, and then depending on how sensitive I set the sensor to be, it would start picking it up as it's reflecting off my hand into the receiver over there. So this is the emitter and this is the receiver. IR is not something we can actually see with our eyes, but sometimes we could pick it up on camera. On the sensor, you have four pins, ground, power, out, and then EN. EN stands for enabling pin. So if you wanted to trigger this on and off and not have it always on, you would use the fourth pin, but we're not going to, we're just gonna use the first three. Three pins means we need three cables. I'm gonna be using a breadboard as always, just because it holds the sensor for me. While I explain to you guys, I'm just gonna plug that in anywhere and take three different cables. One is going to be for the ground, so that's the first pin from the left, second one for the power, which is right next to that, and the last one, which is going to be the output signal. Nice thing about these sensors is it's all built in onto the sensor. We just receive a yes or no, some things in front of me, some things not. So we don't actually have to use libraries and write a bunch of code like we do for a lot of the sensors that we do in these videos. So take your Arduino, plug it into your computer, we're gonna be putting blue into a ground port, red into the five volt port, which is right next to our Arduino Uno, and then yellow, we'll be putting into port number two on the digital side. If you don't know the difference between analog and digital pins, analog pins are very one or zero. They're called high or they're called low. High being a lot of power is going through, low being, this is a low amount of power. So when there's a high amount of power, that's gonna be telling us that this is sensing something and it's passing the power out through the yellow instead of through the blue. So we're putting in power through red, it's going out through blue, in through red, in through out through blue. And then at one point when it actually detects something, it's going to send that signal to the yellow cable, which is going to light up this red LED and let us know, hey, something's be detected. As always, open up your Arduino editor, make sure when you go to tools, board, you're on the right board, port, you're on the right port and you should be ready to go. This is pretty simple. We're just going to do a couple of things. First thing is we're going to declare our LED, which I've plugged it on ready into the board. It's on port 13. We're going to have an input value, which is going to be holding our input pin. And then we're going to have a variable where we hold the word high or the word low. And depending on that, we're gonna know if there's an object or not in front of us. In the setup, you're gonna want to activate the two pins that we plugged into. So pin mode, and then we have LED, since we're gonna be powering the LED and it's not actually, it's not inputting anything, it's going to be outputting power. Just going to take that, copy paste it one more time. And then we're going to do the same thing for input. Now, oh, and then we're gonna have to activate our console, so just do serial that begin and put it on this band 9600. After you've done that, we're going to write the object variable and in here, we're gonna store the digital read from our sensor. So if it's a technique high or low, it's going to store it in here. We're gonna put the input pin in there because that's the pin we're using. And then we have to make a little if statement. We're going to be telling it, if object equals low, which means there is something in front of it. And then we're going to go and just activate our LED. Now it's gonna keep looping and it's gonna keep telling us, okay, something is in front, something is in front, something is in front, until there isn't anything in front and it's going to jump into our L statement, which is going to have serial, not print line. And then in there, we can put let's say clear, nothing ahead. And then we should take that LED statement right here and just call the same thing, but tell it low so that it turns off. And at the bottom, let's make a bit of a delay. Doesn't have to be anything crazy. 300 milliseconds should be fine. All right, now we see that our Arduino is actually activating. I'm gonna refresh it one more time. All right, let's see what happens when I put my hand in front of the sensor. Nothing. And as I move it down, it should activate. Oh, I think we're on. Let's go into our serial monitor. So tools, serial monitor, pull that up right now. It's saying clear, nothing ahead, clear, nothing ahead over and over and over and over. Now I'm gonna put my hand in front. Sensitivity is really low. I had to play with this a bunch before the video. So we'll see what happens as I move my hand closer and closer to the sensor. Oh, there we go. It activates. It's saying something is in front, it's freaking out. As I move my hand back, clear, nothing ahead. Pretend you're driving in your car, you're going to get some groceries because you want food, who doesn't want food. You're going to park in a really tight parking spot and as you move back very slowly, you hear a beep. Now you know, you're too close to the wall and you shouldn't go anymore or you're probably gonna hit your car. As you move away, it'll go away. Move in, beep, beep, beep, beep, beep, beep, move out. And that's what you use the sensor for. If you wanted more precise measurements, you'd have to use an ultrasonic sensor like we used in the previous video that I showed you where we were able to get actual precise measurements on a ruler as we were moving it closer to another object. But the downfalls of that is that it works off of sound and this works off of IR light. I hope you enjoyed this video. If you did, please do consider subscribing and liking the video. About 80% of my viewership right now is not subscribed to my channel. I'm at 1,200 subs, so imagine if 80% of my viewership is not subbed, how many subs I could be at and how far I can get this channel going. So please do subscribe if you're enjoying the content and you wanna see more of it and I'll see you guys in the next one.