Lesson 4: Connecting a Circuit to an Arduino

In the next two lessons, we are going to go over how to rebuild the circuit we built using the Arduino. Instead of pushing the button to turn on the light, we are going to push the button and have the arduino turn on the light. 

But first, what is an Arduino? An Arduino is a small computer that is designed by an Italian company. It is built to make it easy to program and use to build different things. Like a game of laser tag, or a box that only opens on one place on earth. We are going to go over the basics of what an Arduino is, how it works and how to connect stuff to it.


An Arduino is powered by electricity. Without electricity, the Arduino doesn't work. We are going to use a nine volt battery or the electricity from a USB cord to power the Arduino. 

Unlike people, who have five different senses (sight, sound, touch, taste and smell), Arduino's only have one sense. It can sense electricity. We are going to use this sense in a minute to let the Arduino sense whether or not a button is pressed. 

In addition to sensing electricity, Arduino's can send electricity into things. They can't shoot lighting out of them (unless you attach the right things to the Arduino, but that's a topic for another time), but they can send a small amount of electricity out to other devices. We will use that to turn on the LED. Before we do that, we're going to cover some of the basics of what this thing is. Feel free to pull our your own Arduino and follow along.

First, on the right hand side of the Arduino are two black bars that holes in them. These holes are very similar to the holes in a breadboard, and you can stick wires into them to connect the wires to the Arduino. These are called the Digital Pins, and there are fourteen of them. They are all numbered, starting from 0 to 13 (why do they start counting at 0 instead of counting at 1? It's a long story, which we can cover later. For now, know that computers do that, and we will go over it later. Or you can Google it). If you want to plug something into Digital Pin 7, you find the number 7 on the board and plug a wire into the hole next to that number. 

The digital pins are used to sense or send electricity. However, these pins are not as sensitive as some of the other ones. They can only tell if they are connected to a lot of electricity (like the plus side of a battery) or no electricity (the minus side of the battery). We will be primarily using these pins to connect things to the Arduino. They are shown in green below on the Arduino.

digital pins

The power pins, as shown below in red, are connected to the battery (or USB cord) that is powering the Arduino. It lets you connect wires to the plus or minus side of the power source. Like the Digital Pins, these power pins have labels next to them. The label "5V" is connected to the plus side of the battery. This is also called the five volt pin. The two pins labeled "GND" are connected to the minus side of the battery. These pins are called the ground pins. 

Power Pins

To power the Arduino, you can plug a battery into your Arduino using the battery plug, shown in yellow below.

Power Plug

Alternatively, you can power your Arduino using a USB cable, shown in orange below, and then plugging the Arduino into a computer. Note that if the circuit you make uses too much electricity, your computer could get damaged (most computers have protections against this, but it is a possibility).

USB Plug

 Now we are going to re-build the circuit we had last time, with some tweaks to connect it to the Arduino. The first thing is to use a red wire to connect the "5V" pin to the top left hole on the positive power rail on the breadboard, as shown below. We are always going to use a red wire when connecting to the "5V" pin to make it easy to connect things to the positive side of the battery.


Next, we are going to use a black wire to connect one of the pins labeled "GND" to the top of the minus power rail. It's easiest to plug these two wires in right next to each other on the breadboard so you know you aren't plugging them both into the same power rail. Doing that will break the Arduino. This creates the same easy connections to the positive and negative sides of the battery using the power rails on the breadboard that we had with the battery.

Power and Ground

Next, we are going to add the button back, but with some tweaks. First, add the button so that the top left pin is on 5-e. Next, connect the resistor with the orange band between the negative power rail and 5-a. Use a red wire to connect the positive power rail to 7-a. Finally, use an orange wire to connect 5-d with digital pin 9 on the Arduino, as shown below.

Button Circuit

 This circuit lets the Arduino sense whether or not the button is pressed. When the button is pressed, electricity can flow from the red wire connected to 7-a, through the button and into the orange wire to digital pin 9. The electricity also flows through the resistor to the GND pin, but the resistor keeps the electricity from flowing through quickly, so the Arduino can sense that pin 9 has electricity on it. However, when you let go of the button, there isn't any more electricity coming, and all of the electricity goes through the resistor to the GND pin (the minus side of the battery). If the Arduino tries to sense if there is any electricity on digital pin 9 at that point, it won't sense anything, because all of the electricity has gone to the GND pin. This is how, using electricity, the Arduino will be able to tell if the button is pressed or not. And if the button is pressed, we will tell the Arduino to turn on the LED.

To connect the LED to the Arduino, connect the long leg of the LED to pin 25-e, and the short leg to 26-e. Then connect the medium resistor with the red band to 26-b and the negative power rail. Finally, connect 25-b to digital pin 8 on the Arduino.

with LED circuit

This circuit allows the Arduino to send electricity out of digital pin 8 into the LED, through the resistor to GND and turn the LED on. 

Now that we have two circuits: one connecting the button to the Arduino and one connecting the LED, we can move on to programming the Arduino to turn on the LED when the button is pressed. You can move on to that lesson by clicking here, or keep reading for some bonus information.

Bonus Information

I am calling the small computer we are using an Arduino, and while that is true, Arduino builds a couple of different types of small computers. The one we are using is called the Arduino Uno, and it uses a small chip that contains (almost) an entire computer in it. The chip's name is the ATmega328p, and it's shown below.


That chip is the brain of the Arduino Uno. If you pull that off of the Arduino, you could plug it directly into the breadboard (with a chip for power and a clock), and it would work. There are a bunch of pieces of metal, or pins, coming off of the chip. Each one of those is connected to different places on the Arduino board. For example, the fourteen digital pins are physically fourteen of the pins on the ATmega328p chip. The Arduino has small metal wires built into the board that connect the pins on the chip to the holes that you plug wires into on the sides of the board. The entire purpose of the Arduino is to make it easy to program and connect circuits to the ATmega328p chip. That's all it's doing. And, if you wanted to, you could build your own Arduino. Which we will do eventually, but for now, let's get to programming the Arduino.