Page 1 of 1

Led Array in combo with Button Array

Posted: Thu Apr 29, 2021 4:55 pm
by Mike Horsten
HI, I was looking for a solution to have a button array and have a led with the button that is turrend on.
This would be useful for a button box that tells me what is on and what is off. just by looking at the led.

the code i have would use a 4x4 matrix but the leds would consume 16 pins on the Arduino plus the 8 for the buttons. Making it no possible on a NANO (20) or a Raspberry Pico would leave one pin left. Any ways to do this? Or is the mega the only solution. Binding the led to the switch is not possible as they are push buttons not fixed switches.

MIke

PS a Multiplexer or DM16chip would solve the issue

Re: Led Array in combo with Button Array

Posted: Fri Apr 30, 2021 6:01 am
by Sling
There are a few ways to do this. Using message port the options are plentiful but if you don’t want to get into message port then you can also multiplex the LED’s using the standard API digital in and out functions.

Re: Led Array in combo with Button Array

Posted: Fri Apr 30, 2021 6:41 am
by Mike Horsten
Sling wrote: Fri Apr 30, 2021 6:01 am There are a few ways to do this. Using message port the options are plentiful but if you don’t want to get into message port then you can also multiplex the LED’s using the standard API digital in and out functions.
Can you explain the multiplexing with the digital API?
I already use the digital out for one command to switch between two leds red and green and a button, so the button gets pressed, the red led goes on, if i press the button again the green turns on and red off, but i still need 3 pins to do this one for the button and each led gets one. As per the question it only needs to go on and off with ONE button so there are only two pins per button (led and button) but i need about 16 buttons with LED's if you know a way to lower the pin count that would be great.

Mike
PS buttons used are the 12x12mm simple tactile buttons.

Re: Led Array in combo with Button Array

Posted: Fri Apr 30, 2021 10:02 am
by Keith Baxter

Re: Led Array in combo with Button Array

Posted: Fri Apr 30, 2021 11:13 am
by Sling
Exactly that. You will need 4 transistors to turn on the common cathodes unless you keep the led current low enough so an Arduino can drive 4 LED’s at once without risk of damage.

Some may say that the timing is important here and they would be right but in my experience for this number of LED’s it should be no issue. I managed this with raw 7 segment displays and no special driver way back using just AM and a few basic components. I was just testing the capabilities of AM but it was a useful and successful test.

Tony

Re: Led Array in combo with Button Array

Posted: Fri Apr 30, 2021 11:54 am
by jph
Probably not what you are absolutely looking for but ---I always found this fun to play with, even though it was years ago, A forgotten art.

https://en.wikipedia.org/wiki/Charliepl ... ltiplexing.
Joe

Re: Led Array in combo with Button Array

Posted: Sun May 02, 2021 1:36 pm
by Mike Horsten
Thanks guys for all the help but ill use a Mega for this as there are too many variables. Loved the videom but that does not help much but thanks @Keith.

Is there a repository for code somewhere, like a sample code for a button array. I fail to find it. What i need is how to pull the correct value from the array.
Explain: if i have an array of say 2,2 i have 4 buttons. How i know that Air manager will tell me what button is pressed if i ask via the wiki example, but how to translate that to a specific command for a specific button is unclear to my mind.

Any help is appreciated.