I am looking at building a Project (https://www.electronicspoint.com/threads/assorted-gubbins-on-toy-tank.277654/ ) and need to control about 13 LEDs, using maybe 12 Buttons.
I do not have that many I/O pins on the Arduino Micro that I am planning on using (especially once the other parts I need are connected)
I have been pointed in the direction of "Multiplexing", but need to check that I understand how it works.
So:
To manage the 12 Input Buttons, rather than using 12 separate pins, I build a 3x4 matrix of buttons, and write a loop to cycle through each of the 4 Columns, checking which of the 3 buttons is pressed. This uses 7 Pins (4 Column-selector, 3 input).
I run this loop, assigning values to IsButtonXPressed variables, and then move on to the next section of code (do stuff when buttons are pressed).
The code then comes back to the loop, and checks all the buttons again.
I also need to do similar on the Output, putting the LEDs in a grid, and controlling row/columns to light them up.
Am I on the right lines here?
I do not have that many I/O pins on the Arduino Micro that I am planning on using (especially once the other parts I need are connected)
I have been pointed in the direction of "Multiplexing", but need to check that I understand how it works.
So:
To manage the 12 Input Buttons, rather than using 12 separate pins, I build a 3x4 matrix of buttons, and write a loop to cycle through each of the 4 Columns, checking which of the 3 buttons is pressed. This uses 7 Pins (4 Column-selector, 3 input).
I run this loop, assigning values to IsButtonXPressed variables, and then move on to the next section of code (do stuff when buttons are pressed).
The code then comes back to the loop, and checks all the buttons again.
I also need to do similar on the Output, putting the LEDs in a grid, and controlling row/columns to light them up.
Am I on the right lines here?