 A lot of sensors tend to use IR technology. For example, this one right here is a little U-shape. It shoots out light from one side, receives it on the other, and if anything is in the middle blocking it, it shoots out an event, tells you, hey, something's happening. Something's blocking it. Then we have this one right here, which is an obstacle detection sensor that uses IR technology. So it shoots out IR and receives it at the same time, and bounces off with the object in front of it. And as it gets closer and closer, depending on the sensitivity, we'll shoot out an event telling you, hey, there's something in front of you, watch out. For example, we've seen this technology on a lot of cars that have parking sensors on the back in front of them. Then what we're going over in today's video is a tracking sensor that works off of the material it shoots on. And then what we're going over in today's video is this right here. It's a tracking sensor using something like this object detection, but it shoots light onto surfaces and depending on the response of IR light, it will go and tell you if it can see or it can't. So an example is there's a lot of Arduino robots that can drive on a straight black line or like a big circle. And that's because they're using this sensor, either one or multiple, and using the information coming off of the sensors, they're able to detect whether it's falling off or on the line. So for example, right here, I'm on the line and the second I fall off, it's going to tell the sensor, the sensor is going to tell the Arduino and the Arduino's like, oh, well, we got a turn left. It turns left and it's like, oh, we reached, and it's going to go forward a bit and turn right. And then it's going to sense again and it's just going to keep zigzagging across the line. And if it does it really fast, it'll go straight down the line. So what you're going to need for today's video is an Arduino. I have an LED plugged into port 13 and the other side plugged into the ground on the board. And then your tracking sensor, which just has three ports on a G, a V plus and an S, G for ground, V plus for power, S for signal. Take that and plug it into the breadboard and I like using breadboards, these kinds of sensors, because they keep a consistent height. Obviously, if you're using a material that's not very reflective, but you're very close to the sensor, it's going to go and activate it. The cool thing about these sensors is they actually compute all the information, like this one right here and this one right here and near the end, pull an LED on the board. So if I'm a little bit closer enough, you'll actually see what you need to understand. Even though there's no code running in here, it's just what the hardware is doing on the sensor. So put your Arduino on the side, take your keyboard and open up your Arduino editor. The first thing we're going to want to do is declare two variables. The first one is going to be, let me just turn off caps, const int and then we can call it, for example, LED, this is going to be port 13 and then we're going to have another const int and this could be our tracker and it's going to go on port number eight. Then in your setup, we're going to want to tell their program and their Arduino what these pins are going to do. So you just type out pin mode and then in here, we can type in LED and LED is going to be output pen because we're sending power to the LED through the pen. Then under that, let's go and grab our tracker and make it an input pin since the tracker is going to be sending us a signal and depending on the strength of the signal, we can see if something's being detected or something's not being detected. And that's pretty much it. Now in your loop, you can do whatever you want with that data. So for example, let's go and make a interior called value and inside of that we're going to go and call digital read, which will read off of a digital pin and in this case, we want to read off tracker. Then on the next line, we can do whatever we want with that. So let's make a quick conditional statement here. If else, and then in the top here, we're going to say if the value is ever equal to high, then that means that nothing is being sensed and we want to go and for example, turn on the LED search type of LED and then high. Now, if we went and checked the sensor and we weren't sensing anything, we're going to want to turn off the LED. In this case, I have a ready LED. So red LED turning on would be like warning your off track. LED off would be like you're good to go, your on track. Just upload that. Now that we turned it on, we can see the light on the Arduino is strong and bright and that there's no issues with the sensor. If I move something really close to it and it actually senses something in front of it, it's going to turn off the LED and repeat it. Now we can see that the LED on the Arduino is big and bright. If we take our sensor and just put it straight onto something, which is obviously going to reflect back some light, we can see that the LED turns on and off. Let's go ahead and grab this piece of paper with black tape on it and use this to zoom out of what the Arduino car would be doing. It would be going straight with slight left and right motion and every time it goes slightly left and right, if it ever falls off track like that, then we're going to tell it, okay, you fell off track, light back into the sensor and you should go right now. And it's going to go straight, but slightly right and it's going to go and go and boom. And now hit another reflective surface. So the Arduino is going to be like, okay, well, we hit a reflective surface, we're not on the line anymore, we got to turn back left. And it's going to keep doing that. And if it does it really fast and efficiently, you'll be able to go very quickly down the straight line or through an oval track or whatever you would like to do. I think one issue is if you had a lot of curves, you'd possibly fall off track. For example, if the curve went this way and you checked here and then you went this way and the curve continued up, but you just fell off track, the Arduino and the robot wouldn't know what to do. So I think the best thing you can do is get a couple of these, maybe three or four of them. And then using that, you can figure out more specific detail on the tracker going on. So for example, let's say I was going straight and I had four sensors and the two middle ones were sensing the line in the middle. And I went slightly left and now the two top ones are sensing the line. For example, let's say I had four trackers on this breadboard here. The two middle ones sense the back line, the other two outer ones sense the white pieces of paper. If the two middle ones are sensing the line, we know we're in the middle of the track and we're good to go. If I take a left and then suddenly the two bottom ones are the ones tracking the black line, but we know we're falling off on the left side and we would tell the Arduino to turn slightly right and continue doing that. Then if there was a curve, we'd be able to see the curve with more progression because we'd have four sensors versus just one being on or off. If you had four sensors, you'd be able to go, okay, well, three of them just lost signal and only one of them is on the black lines, only the edge. The car is on the line right now. So we should take a hard right and go back on. And then you could do the same thing the other way and it would have more detail and be able to stay on a more complex track since it can sense more. All these videos come out of my pocket and about 80% of the people who watch these videos are not subscribed. So if you wanna do me a favor, give the video a like if you enjoyed it. Subscribe to the channel if you wanna see more of the style of content. Right now I'm just doing a bunch of sensor videos so that you guys can have references when I make actual robots on how to use a specific sensor in a specific setting. Thanks so much for being here and I'll see you in the next video.