 Okay in our last video we connected an LED to our Raspberry Pi using pin 4 and also our GPIO 4 and the ground that was next to it. So today we're going to do basically the same thing only with high voltage. Now we're putting out I think probably about 3 volts through with these. There's also 5 volt pins on the board. You obviously can't do much more than that and if you want to turn on a light or something higher voltage, you're going to need something that allows you to control you know 120 to whatever voltage you need and obviously the Raspberry Pi alone can't do that. So what you need is a relay switch which we have one right here. So let's try to focus on that. There we go. So here's a relay switch. I bought this one off of Amazon. It was under $3 was to something. Now that's a single relay. We can control actually theoretically 2 devices with it. Because what we have here is we have well we have 3 pins that are connecting to our Raspberry Pi. We have a negative, a positive and then the signal pin that goes to your GPIO. You can't really see it too well but it says it right there. It says plus and minus and the third one is going to be your signal. These here is where your high voltage goes in. So let's say you have 120 volt connection. You can connect that into here or here and then you can have the output going to one of the other pins. So what happens here is we have the center pin here and that's going to connect either to the first or the third. And depending on whether this is on or off. Now this one isn't very clearly marked on what the default is. But if I come over here, here's an 8 pin or an 8 relay board. This one has 8 relays on it. I got this one off of Amazon for about $8. So you can figure you can control 8 different devices for $1 each. And both of these I got off Amazon. You could probably get them cheaper in bulk off something like eBay or some other supply site. And this one has the pins here. Let's see if we can get a look at that. So the first pin, they're marked very clearly down here. The first pin is your 5 volt coming from the board and the last pin is ground. And then these are where your GPIOs connect to to turn each one on and off. With this one you want to make sure this jumper is set to JDVCC. And basically if you look here, it's a little bit clearer. You can see it's marked and you can see this one here. It's showing that the first two pins on it are commonly connected. So before we send a signal to it, that's connected. If I was to plug something into this right now, it would be on if I connected to those two. If I connected it to the second and third pin, it'd be off until I turn it on with the GPIO pin. So that's basically the same here. It's just not really marked right there on that. So same thing here. Again, you just connect to more GPIO pins. We're going to work with a single relay here. And if you read on this here, let's see if you can read that. It says that it can handle 10 amps or 250 volts AC. And it also says 10 amps or 30 volts DC. So it says it right on there. This one's kind of, the wording's a little smudged, but you can see it says the same exact thing on these boards. And so I'm just going to plug it right into my board here. So again, we've got ground or negative here, positive, and then GPIO. So going from right to left, negative, positive, and your GPIO. And basically what's going to happen with this is we are going to power this device with 5 volts from the board and then control it with our GPIO pin. So we need one more wire because we have our ground and our GPIO pin there. I'm going to connect to this first pin here. We'll get a look at a diagram on the computer here in a moment, but that's going to be a 5 volt pin. And so again, we've got ground, positive is the middle, and then GPIO. Just double checking for myself, plugging that in there. So I'm going to take my ground pin here from my Raspberry Pi, plug it into the ground there. The second, the middle pin is going to be our positive. And then we're going to have our GPIO pin, so the third pin there. And that's it. It's basically the same exact thing as the powering in LED, except for this device needs 5 volts. And what's happening inside here is there's basically kind of like a coil of wires. And so let's say it looks like this, and you've got the third pin here. So commonly it's like this, and then when you add 5 volts, basically it flips this switch like that. So you're turning either something on or something off depending on where it's connected. And so we're doing that with the 5 volts, and then the GPIO pin tells it when to switch. So now that we have that all connected, let's power on the Raspberry Pi. And there is a red LED on the relay here, and that will flip on and off depending on which way it's connected. So we'll give that a moment to boot, and I'm going to go over to my computer now. And okay, so let's quickly, while that's booting up, we've connected to GPIO 4. That's what we're controlling things with, just like we did our LED. We're using this ground here, although there's other grounds like this one here, or this one here, or this one here. I'm assuming it's fine to use any one of those. And then we connected to our 5 volts here to power the relay. And that same 5 volts can power the 8 switch relay just as easily. So let me go ahead and switch to our shell here, and I'm going to SSH into our Raspberry Pi. Okay, and just like we did with the LED, I want to first enable pin 4. So GPIO pin 4, so what I'm going to do is I'm going to say echo 4, and we're going to echo that into sys class GPIO export. And now I do this, I might get an error, and I'm assuming that that's just because I've already enabled that. That's a guess, because I didn't get that when I first did this, never since then it's been doing that. But everything works fine, I just want to make sure you know to do that. Next we're going to tell it that that pin, we want it to be an output pin. So we're saying echo out, and so we're writing to this hardware just as if it's a file, because on Linux and other Unix and Unix-based systems, everything, all hardware can be written to as a file. So we're saying echo to GPIO pin 4, what direction is it going, it's going out. In would be if it was a button press if we're receiving information. Okay, so now I can echo 1 to turn the relay on or off. When I say on or off, it depends on which way it's connected. But to switch it one way, I can go 1 into sys class GPIO, GPIO 4, and then set its value to 1. And you heard it click there, and now there's a red light on, and where the LED's a little bit brighter. And connection here's a little slow. And now I can turn it off. Perfect. Now let's put that into a loop, just like we did last time when we flashed the LED on and off. Except I'm going to change it, well, we'll write it like this. So you can see it flipping on and off. I'm going to control C to kill that. And what I'm going to do is I'm going to change, I'm going to do that same command, but I'm going to change my values from a half a second to probably 3 seconds. So let's do 3 here and 3 here. So every 3 seconds it's going to flip on or off. Now I'm going to take a multimeter here. Let's focus in on that. I'm going to turn it all the way around to this setting here, which will test conductivity for me. So basically the multimeter is going to put a small amount of voltage through this device. And if it reaches the other end of the multimeter, we're going to hear a beep. So an audible beep. So I'm going to put that down there. I'm going to take my focus here. I'm going to take my red pin. I'm going to put it here to the center connection. Oops. And if I connect here, we can hear the audible beep when the LED is off. So now we know when the LED is off that the first two pins are connected. If I was to switch this around, put the red lead to the center again, and put the black lead to the third pin, you can see we now hear it when the light is on. So now we know which way the voltage is going, or not which way, but which one the voltage is connected to when the LED is on, and which one we know it's connected to when the LED is off. That's it for this tutorial. I'm showing you how to use it in the next tutorial. We're going to use the power something, something high voltage or higher voltage than the five or three volts that comes off the Raspberry Pi. So as always, I hope that you enjoyed this tutorial. I hope that you enjoyed all my tutorials. If you did, be sure to like, subscribe, and share this video. Also check out my website, FilmsByChris.com. That's Chris at the K. There should be a link in the description. There's also a link in the description to some notes on this. And as always, I hope that you have a great day. Okay. This is an introduction to FilmsByChris.com. I'm Chris. That's Chris at the K. That's me right there. My daughter, Amber. And my wife, Jennifer. We pretty much live in the swamps of Florida. I'm a firefighter by day, as well as by night. We work long hours. But that's not why you're here. You're here about the videos I put up on YouTube. These videos are mainly about computers and programming, which means most of my videos look something like this. And if that's what you're interested in, great. If not, that's alright. I do videos on other topics, too, such as video editing, special effects, photo editing, 3D design, and music creation. If you are one of my viewers and you enjoy my videos, my Patreon page is a place where you can go to help support my videos. So I ask that you take the time to go to my Patreon page and look at different levels of rewards you can receive for different levels of backing. There should be a link in the description of this video if you are watching it on YouTube. Otherwise, you can visit patreon.com forward slash metalx1000. And I thank you for your time and your support. Have a great day.