Controlling 63 LEDS with 12 buttons

Hi.
My first post here to the forum.

I am making a project that will control 51 LEDs, plus some auxilliary LEDs (12), so 63 in total.
I am connecting my rows & columns of a 8x8 matrix directly to the Arduino UNO board, using an Atmega 328.
I don't want to use a multiplexer IC.

Even though the LEDs are in a square grid, after perfecting my hardware and software, I will design a custom PCB in which the LEDs are arranged in a straight line, with all the same wiring pattern as was in the matrix of LEDs.

But for my 12 buttons, I don't mind using a multiplexer, or use rows and columns with varying resistors, and have the Atmega 328 sense which button was pressed, based on the resistance/voltage it measures, on an analogue in pin.

For the main 51 LEDs, only 2 will be on at any one time, so it will be a very low current output.

What's the best way to program this?

The buttons will be marked "UP 1", "DOWN 1", "UP 2", "DOWN 2", etc. etc.

When an UP button is pressed, the current LED gets incremented by whatever number (1, 2, etc.)
When a DOWN button is pressed, the current LED gets decremented by whatever number (1, 2, etc.)
After the new LED is turned on, a brief period of time, set by the user, roughly 40mS, the old LED is to be turned off.

That's the basic premise of it.

I could program this in BASIC, but I can't get Great Cow Basic to work on this computer. So.... I'm stuck
with the native coding for Arduino, unless someone can help me.

Thanks in advance

REM If you need clarification on any of these points, please just ask me.
END

I cant offer anything with-in your current requirements..

but I didnt want to ask why no external IC? a MAX7219 chip can control up to 64 leds.. and the default library out there makes it dead simple to use..

(requires a cap and resistor I believe)

... just curious is all.

Thanks

Thanks for your reply xl97.

You DIDN'T want to ask why no external IC?

One reason I don't want to use an IC like the MAX7219 is that it's a 24 pin IC, the MAX238P is a 28 pin.
I don't want more pins than needed.

Another reason: In my mind, it's not necessary.

Another reason: if I had a long span between the MAX238P and the LEDs, I would probably use a multiplexer, so I could reduce the amount of wires travelling a long way. But in my circuit, they are all going to be relatively close.

What is a MAX238P?

It can be done, but you are making things much more complicated for yourself by not using a chip such as max7219.

Perhaps you should explain more about your project. You say that only 2 of the 51 LEDs will be on at the same time, but what about the 12 LEDs? Can they all be on together? What else is connected to the Uno? What other tasks will it need to perform at the same time as multiplexing the LEDs and scanning for button presses?

Also please explain "cow basic" and how it is relavent to your project.

How bright do you need the LEDs to be, in terms of how much current? Experiment by hooking up your LEDs to 5V with various series resistors and measuring the current. How much current is needed to achieve your minimum acceptable brightness in the environments your circuit will be used (indoors, dim ambient lighting, bright indoor lighting, outdoors in sunlight etc). Modern high brightness LEDs are very efficient. You may be surprised how little current is needed for indoor use, but in sunlight is very different.

groundFungus:
What is a MAX238P?

Sorry. Silly mistake. Atmega328P !!

An 8x8 grid of LEDs directly connected to an UNO is going to need 16 I/O pins, which will not leave many for the buttons (digital pins 0 and 1 are used by the serial interface circuitry, so good idea to avoid those). You could put the buttons on an analog pin and use a resistor network, or connect them to the LED matrix and use the scanning for the matrix to also scan through the switches.

Using the UNO to directly control the LEDs will require current-limiting resistors, and normally a large grid of LEDs needs transistors to handle the high current requirements, but with a maximum of two LEDs lit at any given time you can probably avoid the transistors.

Charlieplexing?

josh9point0:
You DIDN'T want to ask why no external IC?

Maybe he didn't want to hear some lame excuse. :roll_eyes:

The MAX7219 is the immediate answer.

You are posing a classic "XY Problem" variant. :grinning:

You simply do not use an Arduino on its own to drive a matrix. Makes no sense. :roll_eyes:

Just get a MAX7219. In fact, if you already have the matrix constructed and it is other than one of the common matrix modules, just get one of these kits

... which contains all the necessary components on a board on which you can simply omit to mount the sockets for the matrix supplied (it's cheap enough to ignore it) and wire it to your own matrix.

Thanks david_2018. I agree, and I like your way of thinking :slight_smile: