DISCLAIMER: If you choose to attempt any of these modifications, you assume all risks thereof. I just wanted to share my experiences here. Neither Fanhome, nor myself, are responsible for any damages that may occur.
Our First Circuit
Now that we have the Arduino programmed with Our First Sketch, we can build our first circuit to test it out. I recommend disconnecting the Arduino from any power (including the USB cable) before adding/removing any other connections.
For this small test, we can use the power provided via the USB cable when the Arduino is connected to your computer. Here is a basic diagram of the circuit we are going to build:
Now, we could just insert some wire into the Arduino’s pin sockets and electrical tape them to the LED and resistor, but there is a much better way. Using a breadboard and some jumper wires, we can create our test circuit quickly, easily, and without any permanent connections. I will be using these items throughout my electronics articles to connect and demonstrate various circuits.
A breadboard is an electronics prototyping device with rows of pin sockets that are internally connected in a very specific ways.
On most breadboards, there is a positive (red +) and a negative (blue -) ‘power rail’ socket row along both sides side of it. In the picture below, I have used green lines to highlight how the sockets in these ‘power rail’ rows are all connected together. By connecting our power source positive/negative leads to an appropriate ‘power rail’ socket, we now have access to that positive or negative power along the entire row.
NOTE: The ‘power rail’ socket rows on either side of the breadboard are not connected to each other. Only along the length, as shown:
The socket rows in the middle of a breadboard are isolated in much smaller groups of pins. This design allows us to connect various components and keep the connections separate. Here, I have highlighted how the component rows are internally connected on a breadboard.
NOTE: Your breadboard may have small letters and numbers for these rows of pins. These are grid locations and can be used to identify a particular socket, such as B4. However, I will not be using these designations as knowing how the breadboard internally works is more helpful in the long run.
Jumper Wires are typically short lengths of wire with standardized pins on each end. These pins fit into both the holes of the breadboard and the pin headers of our Arduino. They are available in different lengths, colors, and with various connectors on each end (such as an ‘extension’ jumper wires that have a pin on one end and a socket on the other). We can use these jumper wires to connect our electronics components together.
The LED & Resistor
A while back, I bought a set of assorted-color 3mm LEDs so I grabbed a red LED from this set. These red LEDs have a Forward Voltage of 2.0-2.2 Volts (V) and an Operating Current of 20 milliamps (mA). Since our Arduino outputs 5 Volts at up to 40 mA when a pin is turned on (set to HIGH), we will need to place a resistor inline with our LED to lower the voltage and current to what the LED expects. Using the formulas from my Power & LEDs page, I determined that we need to use a 150Ω Resistor with this specific LED.
TIP: When putting resistors inline on a LED circuit, it does not matter which side (positive/negative) of the LED they are on – they will work either way. Also, resistors themselves have no polarity – either end of the resistor can be connected to the LED.
CAUTION: It is important to know that each Arduino has maximum current limits. With the Uno, it has a maximum output current limit of 40mA per pin and a limit of 200mA (milliamps) total across all the pins. If you connect circuits to the Arduino pins that try to draw more current than these limits, you could permanently damage your Arduino. With our small circuit here, we are using the resistor to limit the circuit current to 20 mA, so we should be well within the limits.
Wiring It Up
I created this layout in Tinkercad so it would be easier to see the individual components and where the jumper wires need to go:
Using the same green lines as before, I wanted to highlight how the electricity will flow through the internal connections of the breadboard:
I took a quick picture of this first circuit wired to the real parts:
The Results of our First Circuit
By plugging our computer back into the Arduino via the USB cable, it should power on and immediately execute the most recently uploaded sketch. With the test code running, our LED should light up!
Another shot with our LED lit!
Hopefully, my examples and explanation have given you a basic grasp of Arduino programming and how we used it to create a simple LED circuit. Our little Arduino is capable of so much more, and we will dive into a few of those abilities in the next sections.
Next Arduino Page
VARIABLES – Using variables to store and retrieve data