Arduino USB HID Controller

The improved UI Key bindings have added up/down on the 4 standard Encoders as well as assignments for every switch press, short, bold and long.

I’m dreaming of an outboard USB HID keyboard with Arduino Leonardo connected to 4 encoders and converting those to the corresponding keypress actions. Anyone have a work in progress, or suggestions before I order a few and start messing around with this?

My minimalist stage config is now looking like a Pi4 with USB sound card, and then in the studio I’ll hook up HDMI, and an Encoder Keyboard block for twisting knobs and assigning MIDI’s.

Some of this work is done here and adapted/ simplified here. This is an I2C interface but the encoder and button code could be used. There are some HID libraries for Arduino. I am using STM32 hardware and the Roger Clarke libraries which I started to detail here. The idea of a USB keypad was discussed here..

I quite like the idea of a USB control pad but there is benefit from having the knobs close to the relevant part of the screen. Of course that loses some benefit when the screen is 55" and the knob is 20mm. (I couldn’t fit another measurement scheme in that sentence :wink:. )

2 Likes

Thanks @riban!
I remember reading some of this along the way. I was tempted by the USB keyboard, but was limited at the time by issues with the Pi3, which I’ve now replaced. That and the switch press was not yet fully implemented.

I’ve ordered up USB-C plugable Arduino Pro-mini which should arrive tomorrow, the USB-C STM boards should arrive Tuesday.

At this point, I’m leaning towards the STM32 thanks for the tip on that. I think I can connect 5pin arduino style encoders directly with encoder 5v/gnd supplied as GPIO which would make this a straight wire for a nice clean build. I suppose I should also think about implementing S1-S4 since that’s becoming the standard.

Without adding any multiplexing circuitry you need sufficient GPI pins for each switch:

  • 2 GPI per rotary encoder: 8
  • 1 GPI per encoder push button: 4
  • 1 GPI per switch: 4

So that is 16 available GPI which can be challenging on some microcontroller boards. The STM32 development board should be fine. You also need to daisy chain or star wire a ground to each switch, including the centre pin on the encoders. It is unlikely there will be sufficient ground (0V) pins on the MCU board for one-to-one wiring.

If you are using encoders with onboard pull-up resistors then you need to either remove the resistor or wire VCC (3.3V or 5V, depending on the MCU) to the encoder’s VCC / +V pin. This is frustrating because the extra component on the encoder boards needlessly adds to the complexity. (I use raw encoders and build my own board.)

The Arduino Pro Mini is based on the ATmega328 which does not have USB port. The development board may have USB serial interface implemented by an extra chip but this will always be a serial port, not HID USB. The STM32 has built-in USB which can be configured as HID so you may find this the better option. There are other boards that support HID USB but you have purchased those so it looks like the STM32 will be your choice. Feel free to hit me up for help with this. I can share my experience and hopefully ease the development.

1 Like

@riban, Thanks!
Yes, I think we are coming at this from a similar background. I appreciate the advice, and experience.

I misspoke, it’s the arduino pro-micro (ATmega32U4), and I picked for HID or Rubber Ducky support :wink: I probably won’t implement on this MCU since the STM seems to get me closer to what I actually want.

Looking at the STM controller, I am assuming there is some way to turn any of the PA_x,PB_x or PBC_x pins brought out to the edge connector as GPIO. I was then going to divide them into blocks of 5, one output 0V, one output 3v/5v, and the three remaining as GIOP input for A,B,SW If this scheme will not work, I’m going to have to use one of your suggestions.

I’ve done the resistor depop on those encoders before, but I didn’t like doing that. I’m going for off the shelf encoders. That may prove to be too ambitious.

Ah yes the pro micro has onboard USB but only 12 digital I/O pins. Most of the digital I/O pins on the STM32 can be used for digital input. Two are used for USB but it sounds like those are the only ones you need to worry about. I’m not sure if using digital I/O pins as supply pins is a good idea. It will work up to a point but you may find you saturate the current limits which could give some weird results and possible damage the chip. There was a topic on this forum recently about wiring supply feeds. If you don’t mind picking up a soldering iron then you can very easily create a distribution strip of pins by soldering a header strip to a bit of Veroboard.

The first step was to figure out how to get code onto my BlackPill Clone.
image
https://www.amazon.com/gp/product/B07XBWGF9M
I was able to program the STM32 using the Arduino IDE using the built-in DFU bootloader. Here’s a video that walks through the steps required to setup the IDE.

Now the real fun starts…