4
\$\begingroup\$

What I'm planning to do is program a microcontroller to keep track of time and flash LED lights.

The features I would need:

  • Decrease/increase interval between flashes
  • Flash specific LED lights (there will be two different LED colors)
  • Flash multiple LED light simultaneously
  • The ability to space the furtherest LED lights ~6" across from eachother (Lights will be in a single line)

I'm planning on buying Arduino Uno, and these LED lights. I would use a max of 6 LEDS at once.

Would this be all I need to do this?

\$\endgroup\$
  • 3
    \$\begingroup\$ Well, all you really need to get up and running would be your Arduino, LEDs, resistors, a breadboard, and a couple jumper wires. Other than that, everything else you mentioned should be classified as a software exercise, your specialty. \$\endgroup\$ – Faken Apr 25 '12 at 2:09
2
\$\begingroup\$

Since you've not accepted an answer I'll chuck in my suggestions.

Most of the complexity here will be in the software and given your background you should have no issues there.

From the hardware point of view I recommend testing with one LED first with a resistor in series to the UNO pin that it is connected to. The LEDs you link to don't state a current draw, if you can't find this out I would suggest setting your resistor to 2.2K ohms (don't ask why, I just always start there). If it is too dim then reduce the resistance until you find a brightness you are happy with.

Get your hands on a volt meter and measure the voltage drop across the resistor - it should be about about 1.4 V less than your supply voltage but it is always worth checking. (see Martin's answer for more detail on this bit)

Divide this voltage by the resistance you choose and now you know the current that one LED needs to reach the brightness you want. Make sure that this number is less than the maximum output current that the UNO can supply. If it isn't then you'll need to either increase your resistance or use the UNO to drive a MOSFET to switch the LED on and off - to be honest if it is too much then the UNO may well have died by this point or at least be getting hot.

If you wan to drive more than one LED from the pin then you will need to decrease your resistance to make sure there is enough current flowing through the LEDs to make sure that the LEDs are at the brightness you want. Again, be careful not to draw more than the UNO can supply - it's basically going to be a multiple of the current you worked out for the single LED.

If it does increase above the maximum current output of the UNO then you could either spread the LEDs across more output pins or use a MOSFET to drive the LEDs.

Other than that you shouldn't have too many problems.

\$\endgroup\$
2
\$\begingroup\$

You are looking at something that should be relatively straight forward.

Really, the hardware configuration shouldn't bother you too much. The Arduino has more that enough pins to accomodate all 6 led's. As such you can setup the lights in parallel, hooked up to pins on the Arduino, with a breadboard, or however you like, with corresponding resistors.

Flashing the LED's is not a problem either, it would be a matter of setting the pins high. Whenever you need to flash an LED, you simply select the pin and set it high, add a delay for the amount of time you need it to be on, and then set it low again.

Here is an example:

int led1 = 1;
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;

void setup () [
    pinMode (led1, OUTPUT);
    pinMode (led2, OUTPUT);
    pinMode (led3, OUTPUT);
    pinMode (led4, OUTPUT);
    pinMode (led5, OUTPUT);
    pinMode (led6, OUTPUT);
}

void loop () {
    //will flash the led for one second, you can even put conditions on this 
    //(you wanted time?)
    digitalWrite (led1, HIGH);
    delay(1000);
    digitalWrite (led1, LOW);
    delay(1000);
    // add for more led's as needed
}

In fact pin 13 on your Arduino should already have a built in resistor.

Now if you want to blink led's at the same time, you will have to look into things like this.

Cheers.

\$\endgroup\$
1
\$\begingroup\$

You'll want some resistors to limit the current from the Arduino pin to the LEDs. The value will depend on the colour of the LED (as this affects the "forward voltage" of the LED). You caluated the resistance with Ohm's law.

The voltage across the resistor is

$$V_R=5-V_{LED}$$

The current (denoted by I) defines the LED brightness (and if you go too high, you'll find them very bright for a very short period, followed by never being bright again :). The datasheet for the LED will specify the maximum current.

Once you know the voltage and current, it's simply:

$$R=V_R/I$$

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.