Project 1. Blinky LEDs


So now that you have a rough understanding of what it is you’re working with and have gathered all the components you need to get started, it’s time for you to get started. This first project is designed to get your feet wet, and requires only an introductory knowledge of programming.


The first thing you are going to do is take the breadboard and attach your components as follows:

One LED, inserted into two parallel rows. You will notice that the two connecting pins of the LED are different lengths. The long pin of the LED is the Anode, will be connected to Pin 10 on the Arduino. The shorter pin of the LED is the Cathode, and is connected to the ground (-) rail on the breadboard, which is then connected to the ground pin on the Arduino. It is important to connect these pins in this fashion, as connecting them in reverse simply will not work (this is how diodes work; they only allow current to flow in one direction). You should also put a resistor somewhere between the LED and the circuit, because failing to do so could cause the diode to pull too much current, which will cause it to burn out. The value of the resistor, as determined by the colored bands printed on the resistor (a very nifty tool can be found here which will allow you to input the colors and will tell you the resistor resistance), should be between 100 and 600 Ohms. Too much resistance and it won’t be able to pull any current at all, too little and it will burn the diode out. I used a 330Ω resistor, right in the range of tolerable values. (Each LED color and size will require slightly different resistor values. To get an exact value, read the reference sheet that comes with the LEDs; it will tell the operating amperage of the diode. To calculate the resistance needed, divide 5 volts, the operating voltage of the Arduino, by that amperage. For example, a resistor that requires 20 milliamps of current would require 5v/0.02A = 250Ω resistor.)


Once you’ve got the setup complete, you can connect the Arduino to your computer. The next step is writing the program. Ideally, you would have downloaded the Arduino IDE (Integrated Development Environment) from the Arduino website. If you haven’t done so yet, click here and make it happen. This particular code is quite simple, thanks to the geniuses in the Arduino labs: they have written extensive libraries of code that allow end-users to write programs in an almost English-like syntax. The code block is as follows:

int ledPin = 10; //This line, at the very start of the program, defines which pin we will be using to connect to the LED

void setup(){
//If we were writing a more complicated program, we would have something besides comments written here
//This time we will not be using the setup function, because there’s nothing that needs to be set up
//However, we still have to have this here because of how the Arduino programming interface works

void loop(){ //This block of code loops indefinitely, and the main body of the program is always written here
digitalWrite(ledPin, HIGH); //Write a digital HIGH (1) to the pin connected to the LED
//The Arduino will do its technical trickery to make the voltage across Pin 10 go to 5V
delay(500); //The delay function is measured in milliseconds. In this case, it equals 0.5 seconds
digitalWrite(ledPin, LOW); //The opposite of the previous command, it will force Pin 10 voltage to 0
delay(500); //Another delay

So, what you have here is a program that will turn the LED on, wait half a second, turn the LED off, wait half a second, then repeat from beginning ad infinitum. Super fancy, right?

You can attach multiple LEDs to the different pins on the Arduino, put them on different delays, and make multicolored blinky lights for any reason or purpose your imagination can concoct. In project 2, we will explore making the LED fade in and out using optical trickery.






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s