Microcontroller query with more digital pins

Hello everyone, I hope you are doing well !!!! I'm going crazy to get some Microcontroller with several digital pins, I need to make a 10 * 10 matrix and transmit by UART TX, I don't see the reason to use Mega 2560 or 1285p since it would be a waste, the idea is not to use multiplexers, I hope you can give me an idea Thank you

You can use an i/o expander. An MCP23017 uses just two wires SDA and SCK and drives 16 i/o ports. Up to 8 MCP23017 can share the same i2c busgiving theoretical maximum of 128 additional i/o ports.

If you need 20 I/O pins plus the 2 for UART, that's 22 I/O pins. The '328p has 20 I/O pins.

Ergo, you cannot do what you want to do on a '328p without using port expanders or shift registers.

Note that if you're building your own board, an atmega328pb has 26 I/O pins, and comes in the TQFP package (same as SMD '328p), with same flash and ram, as the '328p (I think they're cheaper now too). You need to use MiniCore to support it, and build your board for the '328pb (differences are that A7 and A8 are now also fully functioning I/O pins, not analog input only, and one of the pairs of Vcc/Gnd pins was replaced with two new I/O pins - it also has an extra UART, SPI, and TWI peripheral if you happen to need those).

If you're building your board on perf-board and need through-hole, you're looking at a 1284p or one of the smaller flash versions (324p, 644p).

Either that, or you use shift registers and/or port expanders, which may get in the way of updating it as fast as you want to.

Great, cool!! Thank you very much to both of you! very interesting "minicore" could use the "xtall" pins of 328p as digital pins the only thing is that it would work with the internal ocilalor at 8 mhz, it will be very slow to read a 10 * 10 matrix of buttons and transmit another 328p via UART s 16mhz?

Pepo2009:
Great, cool!! Thank you very much to both of you! very interesting "minicore" could use the "xtall" pins of 328p as digital pins the only thing is that it would work with the internal ocilalor at 8 mhz, it will be very slow to read a 10 * 10 matrix of buttons and transmit another 328p via UART s 16mhz?

The speed of the processor is not an issue here, reading a 10x10 switch matrix is fast relative to human timescales.

The only potential problem is that the internal 8MHz oscillator is only spec'ed to be within 10% of 8MHz, while it needs to be within 2-3% for UART baud rates to match. That said, I have never encountered a classic AVR whose internal oscillator wasn't close enough for UART at room temp and 3.3~5v, though such a chip would be within spec.