LED Help

Ok, I am somewhat new to Arduino programming. I have a current project that involves pins 13-8 on the Arduino Duemilanove. I want it to be setup to where I have a 3 position switch. I want one position to be OFF, the 2nd position to be BLINK, and BLINK needs to blink pin 13, delay 1 second, then blink 12, so on to pin 8. Then the 3rd position needs to be FULLBRIGHT, so all the LEDs max brightness with no blink. Can someone please post a code/tuturial on how to do this? And also, how do I power all this. There will be around 20-30 LEDS (a few hooked to each pin). Thank you. 8)

What kind of LEDs? Some LEDs, you can put 2 in series from 5V, others you will need in parallel but limit the current to avoid damaging the Atmega IO pin.
Or, add an external driver chip, such as ULN2003 for your 6 outputs.
The switch, will that be a rotary kind of switch, where one of 3 pins is connected to a common pin?
How many times is each pin supposed to Blink?
30 LEDs, each drawing 20mA, need 600mA (0.6A). How long will they be on at Full bright?
Do you need to be portable? Or powered from a wallwart?

They can be hooked in parallel, the switch can be any switch, (preferably 3 position), the LEDs need to blink until the the switch switches to OFF or FULLBRIGHT. Maybe 30 minutes on FULLBRIGHT? And I need to be portable.

Just a thought, but a strategy you may wish to try is . . .

If you only want each LED to blink once, you could start by looking at chopping up the Knight Rider Code ( Google Search for it on this Website ).

when you have these LED's flashing as you require, replace the single delay so that it loops " delay(1) " enough times to give you the delay you want ( see " for " statement ); this should allow you to interrupt the flash sequence mid-delay so you can change to the permanent on mode as soon as you operate the switch.

Pick up the switches for " flashing " and " permanent on " using two other IO'S.

If either of these are " On " then start the code you have to run and flash the LED's.

In the delay loop ( described earlier ) add a line of code that checks if the input for " permanent on " is made, and if so:

  1. turn all required outputs on
  2. set the delay counter loop to be 1 less than the total number of cycles for the delay. ( this will stop the delay counter from reaching its final count value until this switch goes back off.

Add a line of code so that immediately after this delay has ended all the outputs are switched off.

I've changed my design. I have it set up where I have a potienometer that controls th blink speed up the LEDs. But, how do I power all this. There will be 25-30 LEDs, and it has to be a battery(s). Thanks again guys. Youve been a big help to a newbie like me.

Post a schematic of what you have in mind.
Your idea for controlling 25-30 LEDs may be vastly different than someone else's idea.
How long do you want it to run for?
Are all the LEDs still controlled from pins 8-13?

OK, this is my new design. Sorry for the low quality of the schematic (I didn't have acces to my computer when it was made). I have it set up to where the pot controls the blink speed of the leds. But, since there will be 30 leds, how do I power all of this? I want it portable and it may on for up to 1 hour at a time. If the code helps, I can post that too.

First thing first, your pot wiring looks wrong. Swap the yellow and black wires, as the center pin of most pots is the movable wiper terminal, which should wire to the analog input pin.

Lefty

You have access to a decent battery? Like 12V?
I would do it like this.
May have to drop to 3 or 4 LEDs per string depending on the forward voltage drop of you LEDs.
If so, add 2 strings of LEDs/resistor to each ULN2803 pin.
Adjust the resistor so you have 20mA per string.

You posted a schematic for my old design. Not the new one that has a potentiometer.

Could I do this? It's called charlieplexing.