This is probably a mental block but I've watched a lot of vids and things but its not sinking in. I understand the limit on LEDs is 8 for an Arduino UNO and that somehow it can be gotten around using a shift register, but I don't understand how I can keep more than 8 on constantly. I am looking to have like 8 on and then 2 others do a flash routine, and if I press a button the other 8 fade and flicker. Not looking for the code but how to use a shift register to get more than 8 LEDs to be on at once. Please help?
What makes you think there is a limit?
Because you think you must drive LEDs at 20 mA and are limited to 160 mA? Most modern LEDs are perfectly bright at 10 mA - or less. Sometimes too bright.
Also explain what your project actually is.
Name changed...but still same person.
What I'm looking to do is light models. I need more than 8 on constantly but they need controlled by the Arduino for startup like fade to full strength and then like flicker randomly on a button press to simulate being damaged.
Perhaps you should explain what "light models" means?
I do always mention that a Nano is generally more practical than a UNO to be incorporated into a final design - and cheaper.
You refer to fading - there are only a few pins on the Arduino that provide PWM capability for dimming.
If you want to control - without dimming - a large number of LEDs, then I always suggest buy two or three of these kits using the MAX7219:
Or these ones
which used to be more expensive but are now actually cheaper and more useful if you wish to stack matrix arrays.
The point is that you do not install the matrix arrays from the kits themselves - or their socket pins, but just solder to the positions on the PCB and you have a durable and reliable assembly to drive your own matrix arrays of up to 64 LEDs per unit.
Why did I say two or three? Well, you can fully assemble the first one as the matrix with which it comes and practice programming it. Then the second one for your current project and the third one - for the next!
Considering the cost, it makes no sense to just buy one!
Models as in plastic model starships. My Arduino startup kit came with an 8x8 matrix but this is probably my block...I'm looking at single or double LEDs side by side in these models. I sort of understand like if I wanted a matrix of 1x4 but I thought it has to be 8 minimum?
And the chips are going to all be in the base which is an 8"x10"x1" acrylic box frame usually for pictures. So that way if something goes wrong I can get to it easily without breaking the model back open. I used an uno because it's what I'm learning on. There are going to be 7 models I'm building that will incorporate leds I want to control in some way shape or form depending on the code I find/write/adapt to dim, brighten and flicker.
Seems like you have all kinds of rules and limits in your head due to misunderstandings or misinformation. Tell us what you would like to do and we will tell you if it can't be done for any reason (unlikely) or how to achieve it. But give us lots of details! Numbers, sizes, colours.
LEDs need a certain minimum voltage to run, depending on their colour, or how many you connect in series. But brightness does not depend on voltage, it depends on current. The current figures you see specified for LEDs are maximums, not minimums. Modern LEDs with 20mA maximum can look bright enough with 2mA. So choose some LEDs you like, buy one or two and try them out: how much current do you need for your models?
To do that you will need a selection of different resistor values between 100R to 1K, and a multimeter.
I'd have to calculate draw per model.... but right now the first model has 4 white, 6 red.
Ok... What size & type of led? Which, if any, fade/flash. How many models? What's the most LEDs any model have?
Ok for the model in question the LEDs are most likely all going to 5mm with maybe few 3mm. Two 5mm are running a brighten up to 200 brightness, flash to 255 then off. They are run by buttons. 1 per each 1. Then we have two blinking Red LEDs and two solid red LEDs and then at least 3 white solid. The solid ones I want to be able to run a "random flicker" routine to simulate damage when a button is pressed as well as take over the blinking ones. I also want the solids to do a sequential power up on button press too (led 1 brightens, led2 brightens, led3 to full 255 etc).
But I do know another model will need at least 10-12 green 5mm LEDs and probably 3 white. Will be running pretty close to the same programming with some changes to what each damage routine does. So max i would say no more than 12-15 per model.
I already have a bunch of 1.8, 3mm and 5mm with the 3 and 5 already having resistors inline for up to 12v. (Bought prewired). So hoping I can avoid buying addressables. The colors will never change except in rare instances on one model which I may just use two different led colors to do the fade from one to the other.
Again not looking for code ... Just hardware requirements. And prefacing: I've only had an Arduino since Sat so, I'm lacking in knowledge here. The one Uno I have is the test bed. Others will be purchased as models progress....but at this point only one is fully together with 1 5 mm warm white and two 3mm green (prewired 12v again). My fade to full worked to power it with no issue but again, only 3 LEDs on one pin. That model most likely will just be hard wired with no Arduino though. It's already soldered in parallel and I don't want to crack it open after glue and sanding.( No paint yet. That's a whole other can of worms for another forum). So this 8 rule haunts me. I've read it and it seems to me more than 8 fries the board somehow.
Well, if you have "read it" then it must be true because no-one would write it down if it wasn't true. This is the internet, after all!
If you change your mind and decide to be more open minded, just let us know.
I don't want to believe it. I want to know where it came from and how to get around it.
I'm thinking shift registers, or I read this for the UNO on a post like mine: "You just need to connect each LED to a different Analog or Digital Pin. Set the pin state with Digitalwrite (pin, High) to switch on and Digitalwrite (pin, Low) to switch off the LED. Repeat for each pin number that you have connected the LEDs to. With 6 analog and 14 digital pins , you can connect 20 LEDs to a Uno. For more than that , you have to multiplex the LEDs or use an addressable LED strip.
Be sure to add a resistor between the Arduino Uno and the LED since the Uno has a 5 V output."
So...with my max LEDS being no more than 15 and 4 at the most on a leg I think I might just be good here
You're good as long as you current limit per pin, and per port, to the limits of the data sheet, Table 30-1:
Notes:
-
“Max” means the highest value where the pin is ensured to be read as low
-
“Min.” means the lowest value where the pin is ensured to be read as high
-
Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification.
Pins are not ensured to source current greater than the listed test condition. -
Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100mA.
2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100mA.
3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not ensured to sink current greater than the listed test condition.
VCC and GND pins are limited to 200mA Each Absolute Max. DIP only have one VCC pin, TQFPs have two VCC pins.
jamstraz:
I want to know where it came from and how to get around it.
I don't know where it came from. My guess would be either from some other confused individual, or from someone more knowledgeable but it was specific to a particular circuit or situation, and you are applying it more generally. There are many ways to get around the limits that @crossroads listed, some are simpler than using shift registers.
already having resistors inline for up to 12v. (Bought prewired).
How are you going to power your circuits? Will you use a 12V battery or PSU? Have you tried these LEDs with 5V? Are you happy with the brightness at 5V?
Let's do a calculation: let's assume the resistor inline with these LEDs was chosen to allow 20mA to flow when connected to 12V, and that the led is red and has a forward voltage of 2V. The resistor has to drop the remaining 10V. Ohms law says R = V/I = (12-2)/0.020 = 500 Ohms (usually written "500R"). If you then connect that led+500R to 5V like an Arduino pin, then I=V/R=(5-2)/500=0.006A or 6mA, so much less than the 20mA that flowed with 12V, and the led will be less bright, although it won't look that much dimmer, because the eye is not linear. It might only look half as bright, even though less than one third of the 20mA maximum. Is flowing.
If you are happy with the brightness at 6mA, then that's good news, because it's much less of a strain on the Arduino, it's chip and regulator.
If you want to get the higher brightness and provide a 12V supply, the simple answer is to use an ordinary npn transistor like BC337. The led's anode is connected directly to 12V, it's cathode to the transistor and the transistor is connected to ground and an Arduino pin. The transistor takes the strain of the 20mA, so the Arduino does not need to. A resistor, e.g. 1K ~ 4K7 connected the Arduino pin to the transistor, and probably less than half a milliamp flows from the Arduino.
They seem bright enough at 5v. I am using 9v dc adapters to power the arduinos I will be using as each model will use one. I've seen the transistor solution but I don't quite understand how to incorporate it without needing a breakout board or some other board holding it.
If you have any choice, always choose 5V adaptors for Arduinos, because they work at 5V. If you provide a higher voltage, that then has to be regulated down to 5V, wasting power and risking overheating and limiting the current that can be provided by the Arduino's regulator at 5V.
If you already have the 9V power supplies, then that's ok. By using transistors as described, you can power the LEDs directly from 9V, so all the Arduino's regulator has to do is power the Arduino itself.
To save money and space, you will not want to use an Uno for each model. I would suggest using Arduino Pro Mini. You can buy them x5 or x10 much cheaper, and you will only need to buy one USB-serial adaptor to program all of them. You can use stripboard, protoboard etc to make a small circuit board for each model, solder the Pro Mini and transistors to that. If you need more than 2 or 3 transistors, you can use a ULN2803 chip instead of the transistors.
I looked for that chip but it seems to be for stepper motors...so confused. Space isn't a problem. All the workings are going to be hidden in an 8x10x1 acrylic box frame that normally is for pictures with a cardboard backing it came with.. That way if something goes wrong I can get to the electronics easily without ruining the model.
Edit: never mind. Must have been another chip. Will these work for the chip?
That chip can be used as a very cheap-n-cheerful stepper driver, yes, but it is far more general-purpose than that. Those modules you found should be ok. Just get minimum number for now and do some testing. You won't need to connect the COM pin when using LEDs. But you will only need them if you are using 9V power rather than 5V power, or if you need to exceed the 40mA per pin or 200mA overall limit.