NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » LED all at once
August 30, 2010 by Pr0ject |
I'm making a project where the LED lights "dance" but I need them all to work at once, but all I'm able to do is so one lights up then closes then another and so on. So I've been wondering is there a way to get them to light up at the same time? |
---|---|
August 30, 2010 by Ralphxyz |
Short answer, yes. If you are lighting the LED's from the MCU there is a limit as to how many LED's you could "light" at one time. You might need to do a POV (persistance of vision) trick and flash the LED's so fast your eye will think they are on all of the time. Check out the NerdKit LED Array to get some ideas and of course search for POV also search the Nerdkit forum for "traffic light" to get some more ideas about lighting LEDS. Ralph |
August 30, 2010 by Pr0ject |
Thank you very much. About that trick and flash thing, anything under 200 millisecond will work? |
August 31, 2010 by hapshetsut |
You say you can only get one to light up at a time? i've been able to make at least ten come on at the same time, so current limits shouldn't be a problem for at least that many. Based on what you said, i think you may be reusing the led_blink software, which is designed to flash only one LED at a time. If you put in as code in main(), say:
it will first configure pin 4 of port C as output, then set pin 4C high, driving the LED. If you then put, say:
it will configure 5C as output and set it high. At this point in execution, pins 5C and 4C should be high and their LEDs should be on simultaneously, and you should be able to repeat this process indefinitely, and the LEDs should remain on until they are told to turn off. You can do this with the following code:
As i said, i've used it to light 10 LEDs, PC1-5 and PB1-5. I have not ever used port A, so i couldn't comment on adding those in. Also, i usually do all my pin configuring as one block right after the declaration of main, eg:
You ought to be able to use this to selectively turn on and off individual LEDs, at least (as i said before) 10 by my experience. Good luck, hope this is helpful! |
Please log in to post a reply.
Did you know that reading a double floating point variable with scanf requires "%lf" for "long float"? Learn more...
|