Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Connecting External Components

In this lesson, you’ll expand on the previous lesson by connecting external components to your Arduino board.

For more information about using breadboards, check out the following resources:

00:00 In this lesson, you’re going to start connecting external components to your Arduino board. In the last lesson, you used an LED that was already present on the Arduino board.

00:09 However, in most practical projects you’ll need to connect external components to the board. To make these connections, the Arduino has several pins of different types.

00:17 Although these connections are commonly called pins, you can see that they’re not actually physical pins—rather, the pins are holes in a socket, to which you can connect jumper wires.

00:26 In this figure, you can see several different groups of pins. This first set is 14 digital pins. There’s also 6 analog pins, and then 5 of what are considered power pins. Let me go over them one by one.

00:42 In the orange rectangle, there are 14 digital pins that you can use as inputs or as outputs. The fact that they’re digital, there’s only two levels that are recognized.

00:51 First is Level 0, which is represented by a voltage of 0V. And then Level 1—or On, you could think of it as—is represented by 5V.

01:03 Going down to this green rectangle, you can see 6 analog pins. These are used as analog inputs only, and they work between 0V and 5V. And last, you have this blue rectangle, which has 5 different power pins that allow you to power external components.

01:23 For this lesson, to get you started, you’re going to connect an external LED and it’s going to run that same Blink example sketch. The built-in LED is connected to digital pin number 13, so you’re going to connect an external LED to that pin. As a good practice, you should disconnect the Arduino board from the computer first.

01:44 Once you’ve done that, now you’re ready to hook it up. Let me show you what it kind of looks like.

01:49 I’m going to flip the Arduino board over and you can see here coming out of pin 13—as an output, in this case—going into the resistor—in this case, it’s that 470 Ohm resistor. Mine’s blue, though this picture has it as a tan. It goes into an LED, and then out of the LED back to ground (GND).

02:11 If you haven’t worked with LEDs, as all diodes they are polarized. LEDs, light-emitting diodes, are sided. The positive terminal is called an anode. It’s generally the longer of the two.

02:25 In this case, in this picture, you can see they’re all on the right side. The negative terminal is called the cathode, and it’s typically shorter. There is one other way that if the LED has already been installed in something and you’re reclaiming it, and maybe the legs aren’t obviously different lengths—LEDs, like this style, the cathode side of the colored case also has sort of a subtle flat edge.

02:48 You can see me pushing my LED around on the table here, and you can see it sort of flatten out on one side and stick. You can also see it here in this photograph—though it’s really subtle—that this is the flat edge, indicated here again with that shorter leg. It’s something I didn’t know before, but it’s kind of a handy trick.

03:10 In my case, I’m going to use a breadboard so I don’t have to solder all those things together. It’s going to look something like this. Coming out of pin 13 on the Arduino, because this’ll match up kind of close to this, I’m going to come into row 14, here—next to 15, 14—into this pin I, then I’m going to connect a resistor here from H14 across to—I guess this would be H18. And then jump here, cross here—again, you can kind of follow the positive voltage traveling across here.

03:45 And this is going to connect a bridge here, coming into the anode of the LED, which is coming across on H20. And then its cathode is here on H21. Then there’s a minor difference between this diagram from the article and how I’ve connected it, which I’ll show you in a moment.

04:07 In pin 21, J, over here to the blue bar. So that, again, this runs all along here, so coming back in, going into the ground (GND). Let me show you what that looks like.

04:24 I tried to duplicate that image as best I could, but I think I got one row off as far as rows 17 and 18. Okay, here you are with the Arduino. Coming out of pin 13 with a jumper into J14, then that’s connected automatically to H14, where the resistor comes in.

04:46 Then that’s coming out, the resistor on H17. There’s the jumper at G from 17 to 19. The anode is in H19 and coming out 20 and then 20, J, is running over here to the blue negative terminal, which then runs back into ground. Load that sketch again, if it’s not already loaded.

05:12 You should see not only the L LED flashing, but this red LED—or whatever color LED you have—will flash along with it too.

05:22 Now I’m ready to replug in the USB cable. And that program was already in its memory, it just needed power again. And you could see the L light and the LED flashing at the same time, once a second.

05:40 Now that you’ve connected some external components, let’s start using Python, and that’s up in the next lesson.

Andinet Enquobahrie on April 11, 2020

cool

Become a Member to join the conversation.