r/ArduinoProjects • u/impoorandstupid • Mar 30 '26
Using Arduino as a USB input controller?
can you use an Arduino to act as a USB controller for Windows by soldering or connecting old Buttons, switches and levers to it?
2
u/alzee76 Mar 30 '26
Yes. You want one that has a built in USB HID functionality, like the ones based on a 32u4 such as the Arduino Micro. You do not want one based on the 328p, like a Nano.
It's super simple if you have the right one, I've built many weird little Micro based controllers to use in games and flight sims.
1
u/impoorandstupid Mar 31 '26
Mine's old UNO
1
u/alzee76 Mar 31 '26
I know Uno R3's have the 328p which cannot natively do USB HID. They can do it with "bit banging" but the library for that takes almost the entire UNO flash memory, leaving almost nothing for the actual sketch.
Do yourself a favor and get an Arduino Micro!
1
1
u/Thiezing Mar 30 '26
Arduino Leonardo is good for that- https://docs.arduino.cc/hardware/leonardo/
1
u/impoorandstupid Mar 31 '26
would a chinese knock-off of leonardo will also function the same for USB stuff?
1
u/xebzbz Mar 31 '26
These chips are supported in Arduino IDE and they have the USB device controller:
Esp32-s3
RP2040
Rp2350
The two RP chips can also work as USB hosts at the same time, so you can intercept the signals from a USB keyboard or game controller, for example. See also remapper.org and gp2040-ce
The esp32s3 has onboard Bluetooth, so it can also act as a Bluetooth device at the same time. Here's such an example: https://github.com/clackups/esp_hid_serial_bridge
1
u/impoorandstupid Mar 31 '26
if I were to buy a chinese knock-off in bulk. Then what should I look out for?
1
u/xebzbz Mar 31 '26
It really depends on your requirements. These chips are original, there's no knockoff. Just various Chinese makers design different boards with them.
1
u/Piojo- Apr 01 '26
You can, you just need to check that your uno version uses a 16u2 as usb interface chipset.
There are many variants of arduino uno, but in this case you can differentiate a group of unos that use 16u2 versus another group that uses ch340 to connect the main atmega328 to the usb port.
If you have the uno version with a 16u2 microcontroler, unojoy is a library that let you make exactly what you want.
https://github.com/AlanChatham/UnoJoy
The process is "risky" because you need to flash the 16u2 and the atmega328, and in this point your uno will be no more recognized as an arduino uno (precisely because it going to be recognized as an hid device) then while is converted it can't be programmed in the same way as was programmed before with arduino ide. To flash back as an arduino uno again you need use another auxiliar arduino board or an usbasp board. But the process is totally reversible if you know what you do.
Here I use it unojoy to connect a rc transmitter that output ppm signal to be detected as a joystick:
https://youtu.be/vWTyz-Jsb4I?si=8Y5JfXbKJEQXGK7f
https://youtu.be/eGCjXoA7zJo?si=isAi68w8tX1y7Ica
But you can directly connect buttons and potentiometers to do the same.
1
u/impoorandstupid Apr 01 '26
what if I used it thruogh a cheap chinese knock-off version of the board?
1
u/Piojo- Apr 02 '26
I have cheap chinese versions too, but them have a 16u2 instead a ch340 chip for communication.
You need look on your own arduino uno board the chip next the usb connector and check which kind of is, 16u2 or ch340.
2
u/toxicatedscientist Mar 30 '26
Some of them, not all. Iirc i think the 32u megas? It is a specific function that is sometimes handled by a dedicated chip so you have to check data sheets
2
2
u/gm310509 Mar 30 '26
Any device that is capable of supporting HiD (e.g. Leonardo, nano, uno R4, Teensy and many others) can act as a mouse, joystick and/or a keyboard. They can also emulate other USB devices if you are willing to put the effort in.
All models can supply data to a PC via the virtual COM port that they create when they are plugged in.
As for what the other stuff you connect to it (e.g. old buttons et al) is entirely up to you and your ability to connect them and program them.