Next Guide:

Getting to Know Arduino : Part 3 : Taking your Temperature

 

Previous Guide:

Getting to Know Arduino : Part 1 : Hello, World!

 

In part 1 of my Getting to Know Arduino, I blogged about flashing an LED (light emitting diode) with the Arduino UnoArduino Uno and how to get started with it using an A to B USB cableA to B USB cable. However, we only flashed the LED that was on the circuit board of the Arduino and we didn't actually get to building any circuitry with it, but in the blog post we did look into the code behind the flashing of the LED.

 

Now, what we can do is the same again, only this time, a little differently. You will need the following, or a variant there of:

 

 

Along with the Arduino IDE installed onto your computer. When you have your parts, you will want to plug them into your breadboard and there is a specific way to plug them in to complete the circuit.

 

The Arduino's input/output (IO) pin sockets is where we then connect from digital pin 13 (D13) through a resistor to the LED to ground (GND). It is important to have a resistor in the circuit to prevent damage to your LED, some Arduino boards have an on board resistor in series with the IO header for pin 13 but it is safer not to take that risk else you'll let the magic blue smoke out and your LED will become an FED (fire emitting diode).

 

If you're unsure as to what resistor to use, you could take the unorthodox approach of using the highest value resistor you can find and scaling down until you find the right one, or you can calculate it. If you're uncomfortable with this, typically a 1Kohm resistor will do, but I often cheat and use an online calculator, if you do not use an online calculator then you will want to use Ohms Law to work it out. Once you've read the specifications of your LED and you know the forward voltage (or just voltage) and the forward current (or just current) in mA (milliamperes) and the source voltage (you can find out from the specifications on the Arduino, but I can easily tell you it is 5volts) then you can work out the required resistor.

 

It is important to get used to being aware of the requirements of the components and not just LEDs you're using and what resistors are required.

 

Here is an example of a completed setup:

 

arduino_part2.jpg

 

 

On a typical breadboard there is a grid referencing system. As you can partly see in the photograph it is labelled A to J along the columns across the top and numbered from 1 downwards for the rows.

 

Here we connect our LEDs positive pin to the digital IO pin socket (from row 2 on the breadboard to pin 13 on the Arduino) while we then connect a resistor (row 1 on the breadboard to row 5) and ground (GND from the Arduino to row 5 on the breadboard).

 

It is also worth to note that the LED is 'keyed' as to its orientation from positive to negative (or anode/cathode). Typically the shorter leg on the LED which also has a flat side to the plastic casing is the negative/ground/cathode side.

 

It has been known that cheap LEDs you can acquire have been manufactured incorrectly and that the casing on the LED has been rotated. So sometimes it is a lucky dip as to whether or not it will turn into a FED depending on the build quality.

Now you can connect your Arduino up to the computer and upload the example Blink program, if you still have the Blink example program uploaded to your Arduino then we will see that the LED will blink in unison with the on board LED 'L'.

 

Equally if we connect the LED to pins 1 or 0 on the Arduino, we would see it blink in unison when there is data sent to/from the Arduino.

 

Since you've now got an external LED connected to the Arduino, you can try connecting a few of them in line with one another, in series. Or, you can alter your sketch so that it will blink an LED from more than just the one pin depending on what variable values you use.

 

Have a go and experiment, if you have any problems then please leave a comment. There's also the element14 The specified item was not found. community group!