Hey everyone! I have an Arduino Uno that only has a lot fewer than 22 pins for me to drive LEDs off of. I'm sure this is a very novice question (I'm beginning to try messing around with Arduinos for the first time in forever) and one of the projects I want to undertake requires 22 different LEDs to be driven independently of one another. How would I go about controlling all of them independently?
(also sorry in advance to the mods if I'm posting this in the wrong spot)
With shift registers and serial data you and address an almost unlimited number of LEDs, using just a few Arduino output pins.
There are also "smart" addressable LED strips (and individual LEDs) that only require one output pin. But the software is more complicated so you have to use a software library.
In both cases, the actual limits are available memory and sometimes by the time it takes to send data to the end of the "string" of LEDs.
You can add port expander chips, or shift registers to get more outputs. Or you can use addressable LED strips or addressable individual LED that only use one output pin to drive a chain who's length is limited only by the amount of memory your type of Arduino has, so 22 LEDs is a doddle on any type of Arduino.
there are lot of ways to do that. Multiplexing, Charlieplexing, Neopixels,
all sorts of IC/Boards like
shift registers,
port expanders like PCF8574, MCP23017, MCP23S17, ...
but also dedicated LED drivers like MAX7219, HT16K33, SX1509,...
It all depends about what you really need and what's available already in your project.
If you describe your project in more detail we might find an easy solution.
You've received a bunch of suggestions. I'm going to make a recommendation.
One of the hard things to do when you're a beginner is to choose from a bunch of options because while you can read about the pros and cons, it's still not always obvious until you've tried all of them.
Go with the addressable LEDs. They cost a little more, but are still pretty inexpensive. You will have far less trouble with wiring and you won't run out of pins on the arduino since they only need +5V, ground, and a single digital output pin.
This is 2024, take advantage of the technologies that make life easier.
What's the physical arrangement? Are all the LEDs on a control panel? Are they in a string, like a gauge? Are they widely separated, like say, feet between some? In short, what's the endgame?