Overview
Page last edited October 05, 2012
Text editor powered by tinymce.
Parts
Page last edited October 05, 2012
Text editor powered by tinymce.
LEDs
In this lession you will use perhaps the most common of all LEDs a 5mm red LED. 5Mm refers to the diameter of the LED and as well as 5mm, other common sizes are 3mm and the large fun 10mm LEDs.
You cannot directly connect an LED to a battery or voltage source. Firstly, because the LED has a positive and a negative lead and will not light if they are the wrong way around and secondly, an LED must be used with a resistor to limit or 'choke' the amount of current flowing through the LED - otherwise the LED could burn out!
There are two ways to tell which is the positive lead of the LED and which the negative.
- Firstly, the positive lead is longer.
- Secondly, where the negative lead enters the body of the LED, there is a flat edge to the case of the LED.
Page last edited October 05, 2012
Text editor powered by tinymce.
Resistors
The unit of resistance is called the Ohm, which is usually shortened to Ω the Greek letter Omega. Because an Ohm is a low value of resistance (it doesn't resist much at all), we also give the values of resistors in kΩ (1000 Ω) and MΩ (1000,000 Ω). These are called kilo-ohms and mega-ohms.
In this lesson, we are going to use four different values of resistor, 270Ω, 470Ω, 2.2kΩ and 10kΩ. These resistors all look the same, except that they have different colored stripes on them. These stripes tell you the value of the resistor.
The resistor color code works like this, for resistors like this with three colored stripes and then a gold stripe at one end.
Each color has a number, as follows:
- Black 0
- Brown 1
- Red 2
- Orange 3
- Yellow 4
- Green 5
- Blue 6
- Purple 7
- Gray 8
- White 9
A resistor with stripes brown, black, orange is 10 and three zeros so 10,000 Ω in other words 10 kΩ.
Unlike LEDs, resistors do not have a positive and negative lead. They can be connected either way around.
Page last edited October 05, 2012
Text editor powered by tinymce.
Breadboard Layout
Turning out the lights might help even more.
Page last edited October 05, 2012
Text editor powered by tinymce.
Moving the Resistor
So, it does not matter which side of the LED we put the resistor, as long as it is there somewhere.
Page last edited October 05, 2012
Text editor powered by tinymce.
Blinking the LED
Now load the 'Blink' example sketch from Lesson 1. You will notice that both the built-in 'L' LED and the external LED should now blink.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Lets try using a different pin of the Arduino – say D7. Move the red jumper lead from pin D13 to pin D7 and modify the following line near the top of the sketch:
int led = 13;
int led = 7;
In the next lesson, we will be using LEDs again, this time, the Arduino will be controlling the LED.
Simon Monk is author of a number of books relating to Open Source Hardware. The following books written by Simon are available from Adafruit: Programming Arduino, 30 Arduino Projects for the Evil Genius and Programming the Raspberry Pi.
Page last edited October 05, 2012
Text editor powered by tinymce.







