I am seeking HW.

I would like to make keyboard with enhanced functions (RGB backlite, macros, programmed profiles etc) driven by some small MCU (Arduino Micro Pro or something similar).

To support communication, it needs to use I2C and SPI(for display and other devices), use USB (to communicate with PC) and use Serial to communicate with other Arduinos/MCUs.

The main function would be scanning keyboard matrix (like from 8x8 to 16x8 in maximal variant). The matrix would use diodes for NKRO (not ghosting, any key combination possible).

It would be really nice to have HW, where I could use 3 full ports as input (or as output) with benefit of reading/writing them with only one assembly instruction for 8bit manipulation, not to cycle over array of pins and manipulate each one independently (digitalRead/digitalWrite, which use tons of instructions to determine ports and pin and then combine them together to obtain one 8bit variable). Something like:

byte dataout,datain1,datain2;

Does anyone know, if there is such nonexpensive MCU and which type it is?

On typical Arduino each port is "poluted" by some importaint communications pins, so none of them can be used as full 8bit I/O.

Second question: Is there a reason, why are the most used communication pins spread over range of different ports and not collected on one port, while leaving other ports as full 8bit GPIO useable?

Thank for all answers.

  • 1
    Seems mostly a problem of how many pins you need for your keyboard. You didn't state, how many pins you need. You seem to need an MCU with native USB support.
    – chrisl
    Commented Jun 23, 2019 at 9:29
  • 1
    Personally I'm a fan of the PIC32. It has 16 bit IO ports not 8 bit (though not all pins are populated on all ports), so you could LATE = dataout; datain = PORTB; for example.
    – Majenko
    Commented Jun 23, 2019 at 10:37
  • 2
    Personally I do not see the need to save some instructions. Mostly you want combined ports to achieve high performance, but a keyboard is operated by a human normally, which is VERY slow compared to an MCU scanning all keys. Or do you need microsecond latency? Commented Jun 23, 2019 at 11:03
  • 2
    You can use shift registers (both parallel-in-serial-out and serial-in-parallel-out) connected to the SPI bus. You can then transmit one or two bytes over SPI, which is extremely fast (8 MHz clock on even the most basic Arduinos). You can daisy chain two shift registers if you want 16 inputs. As others have mentioned, you don't really have to worry about the speed of human input devices.
    – tttapa
    Commented Jun 23, 2019 at 12:03
  • 1
    tttapa+MichelKeijzers: I know that, but was also thinking about some "code elegance" as why do 8 loops of about 50 instructions each for what could be done by just two instructions as well (so in like 200x less). I know I can do it somehow anyway and do all others tasks also somehow (like the USB and manipulation of 20+ WS2812B LED and OLED display and rot. encoder and who knows what else I came with) to not be excesivelly slow, but it counts together fast and I would like for once do it effective, not just pile library over library and compensate unnecessery ineffectiveness with faster HW.
    – gilhad
    Commented Jun 23, 2019 at 12:35

2 Answers 2


I'd go with a Mega2560. Up to 86 IO if you use a board that breaks out all IO pins, otherwise 70 on the Arduino version. With a little attention to the physical chip pin mapping to the board you can have several full 8-bit ports while also using SPI, I2C, and Serial via one of 4 UARTs. I'd recommend keeping Tx(0)/Rx(0) free for comm's with PC via USB adapter for code download/debug. Tx1/Rx1, Tx2/Rx2, Tx3/Rx3 are them free for 0/5V level comm's, or other levels via USB adapter, RS232 adapter, etc.


The expander MCP23S17 (spi), with a CS, is a good extention (16 I/O configurable) That should do it !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.