Transcription
Hello guys, this is Paul McQuarter with TopTechBoy.com, coming to you today from the shores of the magnificent River Nile in order to bring you episode number 29 in our incredible new tutorial series where you're going to learn artificial intelligence, or you're going to die trying.
What I'm going to need you to do is pour yourself a nice tall glass of ice-cold coffee. That is straight-up black coffee poured over ice. No sugar, no sweeteners, none needed. And as you're getting your coffee, as always, I want to give a shout-out to you guys who are helping me out over at Patreon. It is your support and your encouragement that keeps this great content coming. You guys that are not helping out yet, take a look down in the description. There is a link over to my Patreon account. Think about hopping on over there and hooking a brother up.
But enough of this shameless self-promotion, let's talk about what I am going to teach you today. And I do believe that we have a most exciting lesson for you today. And we've learned so much on artificial intelligence, we've done so much work in OpenCV, we've done so much work in MediaPipe that we've really built a bunch of skills inside the computer, working inside of this little artificial intelligence land. But what we're going to do today is we're going to bust out of artificial intelligence land, and we're going to start crossing over that barrier, that chasm between the computer world and the real world. And so what we're going to do is we're going to apply the gesture recognition work that we've developed up to this point to actually affect things in the real world.
Now, there's a lot of things that we could affect in the real world, but I'm going to do a relatively simple example. But once I show you how to jump that bridge, jump that chasm, then once you're in the real world on the Arduino, you'll be able to do whatever you want. You know, you could have relays and and turn things on and off and control things. But my example today is going to be a relatively simple one because it should be components that you already have. Okay? Does that sound good? It sounds exciting to me.
And so what we are going to do is we are going to switch over here and do a little bit of Windows management, a little bit of Windows management. And I am going to switch over here to our build view. And you can see what I have is I have an Arduino Uno, and then I have a breadboard. I have five red LEDs. And kind of my circuit is really simple. Each LED, the long leg is hooked to a pin, a digital output pin on the Arduino. And then the short leg goes through a 220-ohm resistor to ground. And then the ground comes over and is grounded here at the Arduino.
Now, what I have this in my mind is these five LEDs represent my five fingers. Okay? My five fingers, right? You can see my five fingers. So this first LED, this first LED on this side is my thumb. And then this is my index finger, my next finger, my next finger. So these five LEDs represent my fingers. And so I'm going to now see if we can control those LEDs based on hand gestures. Sound pretty exciting? I think it is pretty exciting. I hope you guys enjoy this as much as I do.
All right, so I am not going to step through the history of the Arduino or a bunch of stuff there. I think you can build this circuit. By this point, you ought to know how to hook up LEDs and control LEDs with the Arduino. I will step through the code with you really quickly on the Arduino side, and then we'll switch over to the Python side. And actually, on the Python side, it's going to be pretty, uh, pretty straightforward. And so, uh, I just know some of you might not, some of you guys might not have worked on the Arduino in a while. So I will need you to fire up your most excellent Arduino IDE. And I did not mean to do that. I clicked the wrong button and I got nonsense. Okay, so let me try this again. I'll come over here. I think maybe this is one. Okay, now let me pull this over here. I had this all set up, but something got goofed up somewhere along the way. You know what I hate more than anything is this Windows where it like auto-sizes my windows for me. I don't want it to do that. I want it to be the size I want, and it's always popping it to the smart window business. But I digress.
All right, now I will need to get out of your way so you'll be able to see what I'm doing here. And then I think, I think we're ready to go. Okay, so what we're going to do is we're going to cut, come in, and we're going to set up control of those five LEDs. And I'll kind of pay attention to me on my numbering thing. So, so I'm going to be coming from Python, and I'm going to be sending a command from Python. And that Python, that command is going to be a string. So I ought to go ahead and set up that variable. So I'm going to say string, and the string is going to be `cmd` for command. Okay, so now I've got a variable to catch the command coming from Python.
Now I need to set up my five LEDs. Well, I am going to call, I'll tell you my numbering scheme. LED one, like if I count, what is one? The index finger. Okay, so LED one is the index finger. So over here, LED one is not the one on the left, it's the next one over. This is the thumb, which would be five. So I'm gonna kind of go one, two, three, four, and then this LED on the left is going to be five. And it kind of makes sense because that's how I count, one, two, three, four, five. So I'm trying to name my LEDs like that. So LED1, and that LED1, this LED1 right here, the second one over, is LED1 that is connected to pin 9. So LED1 is equal to 9. And then `int ledTwo` is its friendly neighboring pin six. So that is going to be six. Man, I need to get a jar and how do I have to put a dollar in every time I forget to put a semicolon in? Okay, but I caught it before I ran it. If you catch it before it runs, before you run it, it does not count.
Okay, now we're going to do LED three, or yeah, LED three is going to be going to pin 5. Okay, and LED, `int led`, I've got 9, 6, 5. And then LED four is going to go to pin 3 on the Arduino. And then LED five, right? We're coming all the way back. This is LED five here, and it's coming back over to pin 10. Okay, LED five is equal to pin 10. You can number these things however you like, but I like to just have some logical reason for why I number them the way I do. And that way, as I'm going through coding, it gets to be pretty easy.
Okay, now if we're gonna use those, we're gonna have to do what? Don't forget your pin modes. Because if you don't put in your pin modes, your LEDs do not shine very brightly. That's one of the number one comments I get. Well, my LED comes on, but it's really dim. Well, that's either because you used a 10k resistor instead of a 220-ohm resistor, or you forgot to do your pin modes. So that's just a little pro tip there. So let's set up LED1 as an output. All right. And then let's see if we can move this show a little quicker. And we're going to have five of those. So I'm going to copy that, Ctrl C. All right, and I'm going to paste it four times. One, two, three, four. Okay, so I have out LED one, then I have LED two, LED three, LED four, and LED five. Like how fast I did that? Yeah, that was fast.
Okay, now if we're going to be communicating over the serial port, we need to turn the serial port on. So I will do a `Serial.begin`. Now, normally you think of doing a `Serial.begin` is letting you print, but we are not going to be sending this to the serial monitor. We're going to be throwing it onto the serial port, and then Python is going to jump in and it's going to grab it. Or actually, Python is going to be sending data to us in this, uh, in this case. I don't think, I don't think we've done that before. But let's get a speedy 115,200, 115,200 on our baud rate. Okay?
And then also, because over on the Python side, we're going to have to throw the data to the COM port that we're on here, so we need to see what COM port we are on. And you can see that our Arduino, in my case, is on COM3. But you need to look and see in your case, where is your Arduino right now? Yours probably will not be on COM3 unless you are just very, very lucky.
Okay, so we've got our `void setup` done. So this then closes our `void setup`. Now we are going to come into our main loop. And our main loop is, uh, let me just, let's just make sure that we have the circuit, circuit set up right. So I'm going to do a `digital digitalWrite` and then I'm going to say LED 1 and then I'm going to put it high like that. And then I'm going to come in and I'm going to copy this and then I'm going to paste it four times. One, two, three, four. And then I'm going to come in and I'm going to say LED 2, LED 3, LED 4, LED 5. All right.
Now, why am I doing this? Just before I go too much further, I want to make sure that my circuit is right because it's hard to debug a circuit and code at the same time. So let's just verify that we've got this thing hooked up right. Now, if I do this, what should happen? All those things should light up. So let's run this thing. And we forgot to hold our breath, but we're going to live dangerously here. And boom! Look at that. High five! All five are lit up. So that at least shows us that we can, uh, that we can operate this. And that's going to get annoying after a while with those things shining at us. So I'm gonna just go ahead and make these all low so that as we're coding, those things won't be so bright on us. And also, this kind of group of code, we're going to be copying and pasting. Okay, so now if I run this, everything should go off. Shazam! I'm the magic man, the magic man. Okay, all right.
So let's, uh, let's go. Now, in this little snippet of code, we're going to be using this for most of our work here. Now, this is going to be the magic three lines of code, really. It's going to be a magic three lines of code. We want to get a command from Python, and then what we do with the lights or the LEDs is going to be based on the command that is sent from Python. So we want to read the command, but we don't know if Python has sent it yet or not. So what do we want to do? We want to sit and wait. So what I'm going to do is say `while`, and then `while serial.available available`. Turn the happy little orange. `while serial.available` equal equals zero. Now, what does that mean? If `serial.available` is zero, that means there's nothing there. That means there's no data. So this is saying `while serial.available` equal equals zero. What is that saying in plain English? That's saying like, while there is no data there, what do we want to do? While there is no data there, absolutely nothing. We just want to sit and loop. We want to sit and loop in this, in this `while` loop until what? Until there's data. And then we'll drop out and read it. So this just hangs the program waiting for data. So you see between the open curly and the close curly, I don't put anything because I am waiting for data.
Once data is there, what do we want to do? We want to read it. So I'm going to say `cmd` command is equal to `serial.readString`. That's how we would normally read things from the serial monitor, right? But now, this is the problem. `serial.readString` is looking for some particular end-of-line characters in some particular order. And that is the way the serial monitor sends it, and then that is the way that `readString` reads it. But the problem is, we're not exactly sure exactly how that works. And so we want to be more specific. So we want to be very deliberate that we want to read that serial monitor until we find a specific character. And then over on the Python side, we're going to make sure that we put that specific character. So we're not just going to kind of go with the defaults because the default of what Python does might not be the default of what Arduino does. So we're going to do, instead of `serial.readString`, we're going to go `serial.readStringUntil`. Until what? Until we see a single, a single quote and then a slash R, which means carriage return. Now, you say, well, the little quotes are only supposed to be a single character in Pi, in, in Arduino, you're only supposed to put the single quotes around a single character. And you put in two characters. No, slash R is a special character. It is a single character, the character carriage return. All right, so we are gonna read the serial monitor until it sees the carriage return. And then we're going to go do something else. All right, go to the next line of the code.
Now, what we got to remember on the Python code when we send that command, we've got a what? Tag what on the end of it? That slash R. Okay. A little, little trick here that it doesn't work very well if you just go in and dumbly do the, or blindly do the defaults. Okay, now I have a command. All right, so now I have a command. Well, let's just say what do we want to do if the command is equal? If I got to remember, I got to remember, I am in Arduino, and Arduino wants these. Arduino wants the conditional inside of parentheses. So what if the command is equal equal the string "1"? What do we want to do if the command is one? All right, what do we want to do if the command is one? Well, we want to, you notice how mine is putting the end of the curly bracket when I add the curly bracket? So make sure if it's adding the end curly bracket, that you don't also end in the curly bracket as well, because that would be one start and two ends, and that is a recipe for disaster. Okay, so if the command is one, what do we want to do? Well, this is what this, this is one. So what do I want to do is I want to turn on the one LED and I want the other four to be off. So we're going to come down here and grab this code because this sends a signal to all four of the LED. And we're going to come back into our `if command == 1` and what would we want? Well, we got to remember that the one here is the index finger. And so I want to make this first one what? High. And then low, low, low, low. Does that make sense? And so if the command is one, it is going to turn this LED on, my index finger.
Okay, now we are ready to do this again. And man, when I do this copying and pasting, I really hope that I don't have a mistake in there because then you copied and pasted your mistake. Okay, and actually, what I want to do is I want to get this whole `if` statement, the whole `if` statement, including the close curly. All right, so now I'm going to come here and I am going to now have what am I going to look for? A command of what? Of two. A command of two, like that. And then what would two be? That would be this LED and this LED on. That would be this LED and this LED on. That would be LED one on and LED two on. Does that make sense?
Okay, now home gamers, can you guess what we're gonna do next? Can you guess what we are going to do next? Ctrl C. Okay, we are going to do three, T-H-R-E-E. Okay, so that's going to be high, high, high. LED one, LED two, LED three, high, high, high, like that. See how fun this is? Okay, Ctrl C. Okay, Ctrl V. What is this one going to be? Four, right? And that's going to be high, high, high, high, low. Okay, and now [Music] this is going to be hot. And this one is going to be now five, F-I-V-E. And that's going to be high, high, high, high. I'm going to go ahead and get rid of this down here before we forget about it. Okay, and then make sure that my overall `void loop` is closed. So this closes the `if` statement, and this closes the `void loop`.
Okay, now we've gone one, two, three, four, five. Now I don't want to do every possible combination because some of them would be inappropriate and some of them would be hard to make with your fingers. But let's see if we can just do a few more just for fun. So now we're going to come in and I'm going to say, I'm going to give it a command, pinky. Well, what would pinky be? Okay, that would be one, two, three, four. That would be four only is high, and the other ones are low. If I'm thinking about this right. But do you see why it's important to kind of have a methodology of how you name your LED pins? And so what I'm thinking of them is, I'm thinking of the LEDs as fingers. And so it, and I kind of got them in the order that I normally think of my fingers. So that would be pinky. And then if we are going to do pinky, we don't want to leave out who? We don't want to leave out Mr. Thumb. And so we will get Mr. Pinky and then we will paste him and we will use that for our friend Mr. Thumb. Thumb. Okay, and that would be low, low, low, low. Remember, thumb is five. That's the fifth one. No, no, no, no. Am I thinking about this right? One, two, three, four, and then five is, five is the thumb. Yeah, five is the thumb. If I'm, I have to be thinking about this right. I have to. So this would be high, and then this would be low.
And now we are gonna, another one that we could do is just the inside, which would be like that, your inside fingers. And so let's, uh, we'll just go with what we had with pinky, which I think is what I've got pasted, uh, copied. Okay, so then this one is going to be my in, inside fingers. And that would be low, high, high, low. So that would be low, and then this would be high, high, and then low, low, low, low. All right. And then if we're going to do outside, we ought to do inside. If we're going to do inside, we ought to do outside. And so I'll just come here and then this is going to be my outside fingers. And that would be what? Ah, let's do it like this. The hookum horns, or the outside fingers. We're not counting the thumbs. Okay, outside would be high, and then low, low, high, low, high, low, low, high, and then low. Like that. Does that make sense? Could it really be this easy? I don't think so.
What I do think we should do is I do think that we should, I might be able to test it with a serial monitor just to make sure. Okay, so let's see if we can test it with a serial monitor. I will need everyone to hold their breath on this one. Okay, I really do. We've got to go back to start holding our breath again. Okay, what did I do wrong? And it's probably copied ten thousand times. If before, if before one, ah, one dollar. I gotta put in the jar for forgetting that. Did you guys see that? And did you yell at me? You might be trying to blame me, but really, in fact, one of you didn't hold your breath, and it is your fault. Okay, so I need everyone to hold their breath this time. Boom. Okay, we don't know if it works, but at least it downloaded. So now let's open this up. Okay, now let's see. I think we might want, no line. I'm not exactly sure on this what's going to happen with the line ending because I wanted that control R. It might, I know what it was. We put the, we put the carriage return. So I think we, you can't see what I'm doing, can you? Okay, since we're looking for the end of line to be the carriage return, I think here, the slash R, we want to set this on carriage return. Right? And now we're going to come up here and we're going to see what happens if I just type in one. Let's see. Shazam! Did you see that? Look at that. One. If I can do one, I can do two, and then I can do three, and then I can do four, and then I can do five, and then I can do inside, and then I can do outside. Boom! That worked great. Okay. Oh, forgot Mr. Pinky. Pinky. There's Mr. Pinky. And then thumb. And that's all good. Okay, great. That is working.
Now, the one thing we might have forgotten to do down here, we did the outside, but what if it's just nothing? Like, what if it's a gesture that's not recognized? Well, we don't want it to stay in the pinky position if it's unknown, or the pinky went away. And so we want to just close all this out by the unknown command. Okay, so we will come here and we're going to paste, and that's going to be low, low, low, low. And then this is going to be what? Unknown. Known. Okay, so if we get the unknown, then everything goes dark. All right. And I don't think we need to test that again, but we do need to go ahead and download it just to make sure that when we get over to the Python side, Mr. Arduino is already up and ready to go.
Okay, now let's get this out of the way. Now, what I will need you to do is call up the most excellent Visual Studio Code. And then we don't, we want to come over here, and we are working in our Python folder. I also just look down here and I see because I'm doing so many different series, I am in my MediaPipe environment. So that's good. And now I'm going to add a program. And where are we already, man? We are on OpenCV 45. We are on OpenCV 45 already. Okay, so we're going to have `opencv-4.45.py`. And the dot py is pretty important. And boom, fresh new Python program, just waiting to be written. But what we want to do is we want to start with that program we left off with in lesson number 28. And so I will need you to go to the most excellent [Music] www.toptechboy.com and using this happy little search bar, I need you to search on something like "AI for everyone lesson 28 storing and loading" or something like that. You should get to this lesson. And we come down here to this code, we copy it, and then we come over here and we paste it. And just to reminder, this is the code that goes in and recognizes gestures. Okay, it goes in and it recognizes gestures. And then you can either recognize or you can train, right? You can train a new set or you can recognize. All right, do you remember that?
Okay, so what we need to do is it's not much that we're, it's really not much that we are going to have to do on this side. It is not much that we are going to have to do on this side. And as always, I have to do a little Windows management. All right, we are, we're ready to go here. Okay, so we're going to come up here. Now, the whole trick is, this program already knows how to recognize the gestures. But what we need it to do is send those gestures over to Arduino. And when we send those gestures, toward, we know we got to make sure that we get very crisply. We've got to use the same name of gestures that the command in Arduino is looking for. And we got to not forget our friend, Mr. Slash R for carriage return.
But if we're going to send data to the Arduino, we've got to create a data object. And that data object is going to be, I'm going to call mine `arduino_data`. Okay, that's an object. And what is it? It is `serial.serial`. Okay. And now I've got to tell it in a single quote, what port am I on? And I think I've got to, uh, go like, I think you got to do it very deliberately. COM3. You Mac guys are on your own. You'll have to Google how do you, how do you define a port in Mac? It might be different than this. The port is COM3, and then the baud rate is 115,200. And I think I can just do that. And I think it should work. But if I'm going to use the serial, if I'm going to use the serial, then I have to import it.
Now, you guys that have not been following along in my own old lessons, if you have not installed `pyserial`, you have to do that now. And I think I can show you that. I need to get, I need to get a terminal. Okay, I'll get a terminal down here. And how would you go about, how would you go about, I got to get out of your way a lot further, huh? I guess I gotta, it's hard for you to see that. Okay, we're going tiny here. All right, we're going tiny. So if you have not installed it yet, how would you do it? You would go into the virtual environment that you're working in. So you see I'm in MediaPipe. You don't want to just do `pip install`. You want to make sure that you're with the Python that you're using above. And so I'm, I'm in the virtual environment MediaPipe. But whichever Python environment you're in, make sure you're there. And then you just do a `pip install pyserial` like that. `pip install pyserial`. And then mine is going to go real fast because mine's already installed. At least I think it's installed. If it's not, it's good that I'm doing this. [Music] Okay, so you see for me, it says it's already installed. If yours isn't installed, then it would be, it would be doing that there. Okay. And then I can bring this back down. I'm going to come back to more normal size. I hate being a postage stamp. I really do.
Okay, so now if we, now we've installed `pyserial`, but if we're going to use it, we've got to import it here. And it just is imported as `serial`. And then once I do that, the squigglies go away. But just be very deliberate. It's `serial` all lowercase, dot `Serial` with an uppercase S. And then don't put COM3 here, put your COM port. And then I think we all used 115,200, no commas. All right, so now we are able to read data in. Well, not, we're not, I'm sorry, we're not reading data. And in this case, we're going to be sending data to this object. Our object is `arduino_data`. Okay, now we've got to come down here in the program where we actually learn what the gesture is. Okay, so you know, we look down in this part of the program, there's two parts. There's the part of the program where you're training. Well, that's not going to change because we train in Python. That doesn't have anything to do with Arduino. But when `train` is zero, that means we're recognizing. And then what we do is we, uh, if, if our training is zero, then what we are going to do is, I'm not even in the right place here. This is up above the `while` loop. Okay, I'm sorry. So we're going to go to our main `while` loop here. And same thing here, we've got the `if train is one`, that means you're training. Well, no, I don't want to mess with this at all. I still want to train the way I was training before. But if `train` is zero in this part of the code, I am what? I am recognizing. And what is it that I recognize? I recognize and I determine what my gesture is. Okay. And, and so my gesture is the name of the gesture. And one of the things I do with my gesture is I display it on the screen. I display it on my window. But what else do I want to do with my gesture? I want to send it to who? I want it to send, send it to our friend, Mr. Arduino. Does that make sense?
And so what I will need to do is I've got, I put it here. Okay, right here. Okay, I put it already right there on the screen. After I put it on the screen, I want to go all the way out so I can do a carriage return. I do a carriage return. So right after I put it on there, now I'm going to send it to Arduino. But before I send it to Arduino, what do I have to add to that string, my gesture? What do I have to add to that string, my gesture? Well, I'm going to say `my_gesture` is equal to `my_gesture` what concatenated with, which is plus, and then what? The single quote. Which direction does this go? Do you remember? Was it this way? No, it was the other way. That way, slash R. I'm looking to make sure that I'm doing this right, man. This is, this is, this is wrong. It's the other way. It's the one that's above enter, like that. And how do I know? Because it turns, uh, it turns purple. I'm dyslexic, so it is a dyslexic person's nightmare to figure out whether you got a forward slash or a backslash. But I know it's right because our friend, Mr. Visual Studio, is labeling it purple, which means it recognizes that character. So now I've got my gesture, which would be like O-N-E-1, and now I'm putting that carriage return on the end of it. And now I need to pack it up and send it out. So I am going to do a an `arduino_data.write`. And what do I need to write? I need to write `my_gesture`. Okay. And it's all ready to go.
Now, the one thing I also need to do is I've got to put, I've got to format this for the serial port. So you just do an `encode` like that. And then that creates a string that will play well with the, uh, with the serial port. So if you just send `my_gesture`, you can kind of get some strange results. You've got to take the `my_gesture` and you've got to encode it. And it has the slash R on the end of it. Could it really be that simple? Could it really be that simple?
Okay, we're going to run this and we're going to train it. We're going to run it and train it. But what you've got to see is, you've got to see it's going to run. But the real question is, is it going to get that data data over to Arduino? And this time, as we're training, we got to be very mindful to type the names of the gestures exactly like the gestures that, exactly like the gestures that Arduino was looking for. And so I need to, I need to kind of call that program up. I'm going to move it out of your view, but I need to be looking at it just to make sure that I, uh, don't forget what these were. Okay, so now we're going to come over here. I don't think we really need to hold our breath this time because I think it's going to run. But the real question is going to be, is it going to recognize when, you know, is it going to control the LEDs? Okay, so let's run it. And so far, it's looking kind of happy. That's good. I didn't get like an immediate error.
Okay, enter one to train or zero to recognize. I guess I gotta get a little bit smaller so you guys can see it. I can stand to be this small for a little while. Okay, so one to train or zero to recognize. What do we want to do? We want to do one. We want to do one to train. Now, how many did I have? I gotta go back and check. One, I got one, two, three, four, five, six, seven, eight, nine. I've got nine because unknown is just going to come over as unknown, so I don't have to count that. So I'm going to, I'm going to train it for nine. Okay. And then what do I want to call them? One, two, three, four, five. Not six, but then after five, we did, after five, we did pinky, and then we did thumb, thumb, and then we did inside, and then we did outside. Okay. And then file name for training, I'm going to put it as LED. Oh my goodness. Okay, you know what it does? It's renamed my camera here, and I hate it when that happens. You know, when I load, when I load Wirecast, I'm never sure what camera is going to be where. And so I think I will try four. If zero doesn't work, sometimes four works. So, and then I'm going to do just a real quick thing here, just to make sure we get our camera working. This is kind of a disaster, isn't it? All right, so we're going, I'm just going to say recognize this time. I, I'm going to say zero to recognize. Zero to recognize. Okay. And then I'm just gonna go default. And that darn side, that darn thing is happening again. It is not wanting to load my, what webcam? This is bad. Let me see if I can just fire that, you know what I did on my webcam? On my webcam, all right, that is working there. And you're just going to have to bear with me on my webcam. I reloaded the drivers and it has been acting a little bit strange since then. I'm going to try this one more time. Zero to recognize. Okay, so it definitely doesn't like four. We're going to try zero again because it's working out on just a simple program. So I just got to get it working now with this. Zero does not like zero. So we're gonna try one. Okay, zero to recognize. Does not like one. Does not like two. Okay, believe it or not, who would have guessed it was camera three? That is really, really strange for a lot of different reasons. But now we are, we see that it's camera three. Okay, so now we're going to run it for real. Now we are going to run it for real. Okay, so we've got camera three. We're running it for real this time. I'm gonna come back to a larger size because I think I code better when I'm not so small. Okay, so I am on camera three. We're going to run this thing. Okay, do I want to train or recognize? I want to train. Number one. Okay, how many gestures do you want? Didn't we say none? Didn't we say none? I think it's nine. Okay. And then gesture number one is one, two, three. You see, you've got to make sure you do it exactly the same. This would be bad because I did it with an uppercase F. Four, five, and then we have pinky, and then we have thumb, thumb, and then we have inside, and then we have outside. Okay. And now, what do I want to save it under? I'm going to save it under, I got to get out of your way again. I gotta save it under, I'm gonna save it under LED. So we don't have to train every time. And then click enter. And then hopefully the magic will start happening. Okay, it looks like that it's wanting to see a gesture. So I'm going to pull this up. Okay, there it is. And it's recognizing. And it wants the number one. So I've got to give it a nice clear one. Okay, it wants a two. He wants a three. He wants a four. He wants a five. Okay, it wants a pinky. It wants a thumb. It wants inside. I got to be careful with this one. Be careful, guys, when you do this one. Okay. And then it wants an outside. Like that. Boom! Did you see that? It worked already. Okay, now look, there's no gesture there. It's unknown. Okay, it's unknown. But we give it a one, we give it a two, we give it a three. Who's your huckleberry? Look at that. Is this fun or what? So let's do it. Okay, unknown. Everything's off. One, two, three, four, five. Okay, okay, it wasn't recognizing the five. And you see it kind of, like, if you go where it doesn't see it, but it's recognizing it over a pretty good range, right? And then we had outside, and then we had inside, and then we had, we had thumb, and then we had pinky. Okay. But you see what I want to make sure you guys don't be looking up at the screen. You're supposed to be looking down here. You're supposed to be looking at the LEDs. You see the LEDs are matching my hand, my hand gestures. Okay, there's your pinky. There's your outside. There's your thumb. There's your, be careful, be careful. I'm going to give it some help here. Okay, there. Oops. Give me an unknown. Okay, there it is. Inside. That's kind of a hard one. Okay, so that is working pretty darn incredibly well, man. Just take it in. Is this as exciting to you guys as it is to me that I'm controlling things in the real world based on hand gestures? And so I want the light on, I can turn the light on. Now, what I could do, I could turn it on and leave it on. Like I could have an on and off. I could turn it on and I could turn it off.
Okay, guys, why did I do the LEDs? The reason I did the LEDs is because everyone should have the LEDs. Everyone should have LEDs. And since everyone should have LEDs, that's a good thing for us to, that's a good thing for us to to to use. And the second thing is, almost no one, I, I'm not aware of anyone in all of history who has ever killed themselves with an LED. And so it's something that you can break out of computer land, AI land, and you can come out into the real world and you can do it in a way that you don't hurt yourself.
Now, what you could imagine is the really exciting thing would be to get in your kid, or to order some relays, and then you could turn real things on and off. If you were using relays, or you could use the Arduino then to, you know, maybe communicate with other parts of your home through, you know, like maybe if you put a Wi-Fi module on it or something like that. But you see, all of a sudden, once you get to Arduino, then you can start controlling things in the real world. And you could do that like through relays. Now, why am I not doing relays? Because you really got to know what you're doing. And no matter how, how carefully I tried to teach you, there would be someone out there who would get a little 89-cent relay and try to run some big 240-volt, 12-horsepower motor on it. And then, you know, hurt themselves or catch something on fire or something. So I just don't teach anything associated with line voltage, like home line voltage. But you guys that, you know, have electronics backgrounds, you could imagine getting the relay and doing some really, really cool stuff with what I have taught you here.
Okay, guys, man, I am hoping you all are having as much fun taking these lessons as I am making them. This is just an incredibly, incredibly exciting lesson to me that we did today. And I hope you guys are enjoying it. If you enjoyed this video, give me a thumbs up. If you haven't already, make sure you subscribe to the channel. When you subscribe, make sure you ring that bell so that you get notifications when my future lessons come out. And then share this video with other people because the world needs more people that are working on engineering and coding, and fewer people sitting around watching silly cat videos. Paul McQuarter, coming to you from the shores of the lovely River Nile. I will talk to you guys later. [Music]