Hi i was wondering if this would work?
yea
dont know about the micro, but on most arduinos pin 1 is a serial pin so it might interfere with uploading, or give you a interesting light show while uploading
Ok I will fust move everything up a pin .....and thx
Make sure you only have 1 LED on at a time.
Y only one led?
So you don't overcurrent the IO pins by trying to source current into two or more LEDs, or sink current from two or more LEDs, at the same time.
Oh well then how am i supposed to light up more than one led at a time.......like having one row light up after the other......how do people on youtube do it? Lol
Multiplexing. Your code turns on 1 LED at a time, changing to the next LED every mS. So every 15mS all the LEDs get a chance at being on.
Yea i know that.....thats how i have it setup and wired but wat if i wanted the whole row on for a few seconds?
You still multiplex.
Or make sure the current limit resistors are large enough so that only 8mA is going thru an LED.
just like a tv, you only put one led on at a time, but you do it so fast your eye sees the entire picture
What kind of resistors am i talking about and i figured out the multi plexing part for the row after row thing....thanks!
Resistor value is determined by LED forward voltage.
In general,
(Vsource - Vf - Vsink)/current = resistor value.
If your output was 4.8V, and your low voltage was 0.2V (because there's a transistor between Vcc and the output pin, and another transistor between the outpin and Gnd), you wanted 8mA of current, and the LED had a Vf of 2.2V (common for Red), then:
(4.8V - 2.2V - 0.2V)/.008A = 300 ohm
The resistor will dissipate some power: P=I^2 * R = .008 * .008 * 300 = 19mW, so 1/8W or 1/4W resistors will be fine.
Inexpensive carbon composition, wirewound, pretty much any resistor will work.
Of course, if you use a 4 by 4 matrix, you can have an extra LED.
The general solution to the current problem, is to bite the bullet and use column driver transistors (with base drive resistors) so that you can drive a number of LEDS in a row at once.
Otherwise you are indeed limited to either restricting your individual LEDs to a third of the maximum current available, or driving only one LED at a time. These two options are actually equivalent if you consider it. You might be tempted to spend more time driving the LEDS you actually want to be lit, one after another, and not "waste" time selecting but not driving LEDs that are not lit, but this would make the brightness alter depending on how many LEDs are on "at once" though technically, the total brightness would be the same.
If you want more than one LED (actually) on at a time, this will not help you, but have you studied "Charlieplexing"?
I think instead of buying more resistors i think ill just stick with multyplexing big thanks to cross roads for all the help.
Will someone give me an example code like every row lights up one after another. Thx in advance. Pic is attatched.
Of course, most could give you a 'sample code', as you put it (albeit a rather specific one) but that wouldn't really benefit either party involved.
You've made no mention of what you've tried, nor what type of display it is i.e common-cathode or common-anode.
But what I will do is give you some pseudo code. Going from your drawing, I'll assume that D6, D7 and D8 are the cathodes. You'll need to flip high/low states if that's not the case.
- use digitalWrite to set pins d6, d7 and d8 to LOW
- use digitalWrite to set pin d5 HIGH
- delay for some time
- use digitalWrite to set pin d5 LOW
- Repeat steps 2-4 once each for pins d4, d3, d2, d1
Note: while you 'only' have 3 leds attached to each of d1-d5, you have 5 leds attached to d6-d8. The implication is that if you try to power all 15 leds at once, you'll burn out pins d6,7 or 8 - UNLESS you have some current limiting resistors on each of these 3 lines too.
Leds often draw 20ma (white ones often more). The most any single pin can supply or sink is about 50ma (check this number, I forget its precise figure) There is also a limit for the device, which applies in addition to the limit for any single pin. Check this number too!
They are white leds......i want them to just have the rows blink one after another just as an example for me to go off.
I cannot recall just how much actual code you have written before. Did you get the red/ blue "Police beacon" exercise going in the end?
This is always a step-by-step process. Start with the archetypal "blink" program that is already in the Arduino examples in the programming environment, blinking the on-board pin 13 LED. Make sure you have that working.
Now calculate the resistor value for your white LED to draw 12 mA (somewhat less than 40 mA divided by three columns - note that you need to put the resistors in the column wires if you indeed propose to light one row at a time) - I figure it to be about 110 ohms based on 5V supply, 0.2V drop in the high and low drivers, and 3.2V for a white LED, a somewhat less conservative figure than "Crossroads" quoted you but substantially more conservative than your 68 ohms. Now just re-code the "blink" program to flash one of the LEDs that you have connected by first setting the row driver high or low, depending on whether the rows correspond to anodes or cathodes, then setting one column driver to whichever polarity corresponds to the column connections to the LEDs. After the first delay, just turn off the column driver (noting that in the initialisation section, you set all the array pins to outputs).
Next step, once you actually have one white LED blinking - and it is the one that you expect to be blinking because you have correctly identified all the connections, then you add the statements to set the other two columns (each column having its own resistor, rather than the rows having resistors) adjacent to the first such statement so that all three appear in sequential order. You do the same immediately after the first delay instruction to turn off each column.
Once that is working, then you can activate one row after another most simply by copying and pasting the whole "loop" code (except the second delay instruction after the columns are turned off, as you do not wish an "off" interval) four times - so that it appears five times in total, and edit it so that the first iteration turns on what you presume to be the first row, the next iteration the second row and so on. Note the format of each iteration - turn the row on, turn on whichever columns you wish to be lit, do the first (now, only) delay, then turn all columns off (but do not worry about the row which will be set in the next iteration).
Once that is working (but not until it is doing so correctly), you can consider folding all the repeated instructions in a loop. The following step - if indeed you need to do anything more than this - is to read the individual LED on/ off values for each row, from a master table of some sort.
Paul__B:
If you want more than one LED (actually) on at a time, this will not help you, but have you studied "Charlieplexing"?
Its a myth that you are limited to one led (at any instant in time) with charlieplexing. You can light whole rows or columns at the same instant. Of course you then have the max current per pin issue just like you do with vanilla multiplexing, but you overcome that in similar way(s).
Paul