Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

LED And Delay/Clock Question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

LED And Delay/Clock Question

by jssavage10 on Tue Apr 07, 2009 9:41 pm

Hello,
I am brand new to the Arduino, well any sort of programming. I have read up on the code and think I have a decent idea of what I'm doing. I want to create the LED Menorah I'm sure many of you have seen at http://www.evilmadscientist.com/article.php/ledholiday. It drives eight LED's, one per day except for one which is on the entire cycle. First of all is that possible to do with Arduino?
If so, the questions that I have are how do you supply equal voltage to each LED as more are turned on each day? I know you can use HIGH and LOW on the digital pins, but does that just apply all of the power available? Then there is the analog pins which you can regulate the voltage through, but there is not eight analog pins.
And how would you tell it to wait a day between each one? I know there is a delay function, but it runs in milliseconds and it doesn't seem reasonable to use for that length of time. Is there some sort of clock that you can use?
Thanks for the help.
Jack Savage

P.S. Remember I'm just a novice, please don't get upset with me.
jssavage10
 
Posts: 2
Joined: Tue Apr 07, 2009 9:07 pm

Re: LED And Delay/Clock Question

by jerrya on Tue Apr 07, 2009 10:48 pm

Sure, Arduino can do all that.

Turning a pin HIGH simply supplies 5v to the pin. You'll have to limit the current to the LED with a resistor of the right value (google for led resistor calculator). The controller in Arduino has limits, but 8 LEDs shouldn't be a problem. The digital HIGH value always outputs 5v. It's up to the circuit attached to the pin to determine how much current (amps) is drawn from that pin.

The six PWM pins can use the AnalogWrite() function, which is not truly analog, but rather a pulse of 5v with a percentage of time on and off. These are great for dimming LEDs, but if you move your eyes or the LED quickly, you'll see the flashing on and off.

You can use delay to wait a day. Just do the math to figure out how many ms that is. There used to be about a 9 hr limit to counting ms, but now it's much larger, 55 days or something zany like that.

If you want a clock, there are real time clocks (RTC) that you can add on.


Be sure to do all the tutorials, and much of this will make plenty of sense. Only the RTC isn't covered.

http://www.ladyada.net/learn/arduino/


I hope that helps!

jerrya
 
Posts: 17
Joined: Wed Apr 01, 2009 10:49 am

Re: LED And Delay/Clock Question

by jssavage10 on Wed Apr 08, 2009 12:15 am

That is very helpful. Thank you!
Now I just have another question about the voltage. I understand that you need to resist the current to the LED's but I think I might be mistaking some basic electronics knowledge. If you apply the voltage to a single LED, but then to a pair of them, does the voltage not split between them (half on each LED)? The same question on the rest of those needing to be lit? (This question is asked assuming I use the digital pins on HIGH)
Thanks again.
Jack Savage
jssavage10
 
Posts: 2
Joined: Tue Apr 07, 2009 9:07 pm

Re: LED And Delay/Clock Question

by dragonuv on Wed Apr 08, 2009 6:17 pm

[quote="jssavage10"]If you apply the voltage to a single LED, but then to a pair of them, does the voltage not split between them (half on each LED)?[quote]

that's right, leds do have a certain amount of resistance, and the more leds you put in series the less light they can provide.
therefore it is recommended to use a resistor and a led for each pin.

btw, wasn't it Hanuka already? :P
dragonuv
 
Posts: 235
Joined: Tue Dec 04, 2007 1:22 pm

Please be positive and constructive with your questions and comments.