[MUSIC] This lecture's about the General Purpose Input/Output Pins on the Raspberry Pi B+. So this is a layout of what the Raspberry Pi's pins look like. Now there's several different Raspberry Pis, we're using the Raspberry Pi B+, which has more pins, it actually has 40 of these pins. And so if you look at the picture, there are 40 pins, two rows, 20 pins each row. There are other Raspberry Pis, like the Raspberry Pi B and the Raspberry Pi A, and those have 26 pins. So, the stuff that I'll be talking about is generally applicable to all of the Raspberry Pi versions. But we'll be talking specifically about the pin layout on the Raspberry Pi B+. And if you wanna apply this to other Raspberry Pis, you can just look at their pin layout, it's the same ideas. So there are a lot of pins, two rows of pins. And this is similar to the Arduino, the Arduino had the pins on the sides. Our Raspberry Pi has them all together in one block on one side of the board. So if you look at the pins, you could generally group them into the dedicated pins, dedicated power and ground pins. So several of these pins, all they do is output power and ground, which you can use to interface with other devices. So say you wanna have a breadboard, wire up a circuit, you need power, you need ground, you wire them to these pins. So that it's a common power and ground. So, now remember, the Raspberry Pi actually, its pins run at 3.3 volts, so 0 to 3.3 volts. So you got several pins, two pins actually, pins 1 and 17 are 3.3 volts, they just supply 3.3 volts. You also have pins that supply 5 volts, pins 2 and 4 supply 5 volts. You need that because there's still a lot of 5 volt devices out there that need 5 volts, so the board supplies that too. Although remember that the output pins in the Raspberry Pi, when you drive outputs, they're gonna be 0 and 3.3 volts. And when you take inputs, they've gotta be 0 and 3.3 volts. You can't have 5 volts coming in or going out. But it supplies 5 volts for other parts in the system that you might wanna be running that need 5 volts. And then there are several ground pins, 6, 9, 14, 20, 30, and 39 are all ground pins that are on the board. So a lot of the pins are dedicated, the power, the ground and so on. But then the rest of the pins are general purpose pins and some of those are multi-function pins. So general purpose, GPIL stands for general purpose input/output. So a GPIO pin is just a pin that can be used as an input or an output, and this is the same as on the Arduino, right? All those pins were input/output, except for the dedicated power and ground, they're input and output, same thing here. So you've got GPIO, and they're numbered GPIO. Here we've got GPIO2, GPIO3, and GPIO4. Notice the numbering, this will come up later. But the number of the PINs, there are two different names for these pins, right? You can call them 3, 5 and 7, or you can call them GPIO2, GPIO3, or GPIO4. So the pins, all of the rest of the pins besides the dedicated ones are GPIOs and that means that you can control them programmatically. So you can write code that sits in the high or low, and you write code that reads the values that are driven on to them from external sources. Now, all of the pins labeled GPIO are that way. Now notice that some of these pins, if we look at the three pins we got up here, two of these pins are actually, they have two names, right? There's GPIO2, if we look at pin 3. It's labeled GPIO2 and then SDA1I2C. And then GPIO3 is labeled SCL1I2C. So they've got two names, so we'll call those multi-function pins. They can serve multiple purposes. They can act as either GPIOs where as a programmer you could just access them directly. Or they could serve another, an alternate function based on their alternate name, right? So just from the name of these pins we can already tell what their function is. And it's good to get familiar with these things because when you look at boards, you look at the pin names, and just from the name you can tell what the pin's for. So this is SDA and SCL, these two pins. And so if we remember from previous courses, SDA and SCL, the communication pins for the I2C protocol. So those two pins are actually part of the I2C protocol, actually it says right there, ISDA1I2C. But if you remember I2C is a two-wire protocol, two pins, SDA, SEL. So these pins can be used for alternate functions as well, some of them. And notice pin 7 is just GPIO4, and it doesn't serve any special function, it's just general purpose I/O. But some of these pins have dual function. So let's start talking about some of these multi-function pins. Right here we'll talk about the UART pins. So UART, if you remember from when we were talking about Arduino, we covered UART. UART is serial protocol, single bit, one bit at a time is being transferred. So these two pins, they're GPIO14 and 15 but they are also UART0_TXD and RXD. So TX stands for transmit, and RX stands for receive. So if you remember UART, basically you're sending one bit at a time, and TX is the transmission pin. So if you wanna send serial bit, serial data, UART data from the Raspberry Pi to another device, you send it on the TX, and on the receiving end, you receive it on the RX. That's the common way to do it, TX for transmission, RX for receiving. Remember that if you remember with the Arduino, we actually didn't use these pins. The Arduino has pins that can be used for that, but we didn't do that. When we used serial protocol, when we used UART, we actually did it over the USB input. Which is another way to do it. But generally USB is convenient for the Arduino. You can do that with the Raspberry Pi, but an alternate way which only consumes two pins, which is kinda nice rather than consuming the whole USB port, you can just use two pins, is using these two wires. So if you say had another Raspberry Pi, you could take the TX and RX of this one, connect it to the TX and RX of the other one, and they can talk to each other. Thank you. [MUSIC]