In part 1 of my Getting to Know Arduino, I blogged about flashing an LED (light emitting diode) with the and how to get started with it using an . 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:
- (of appropriate rating of resistance measured in ohms)
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:
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!