KVM Uses Many Arduinos

The Arduino platform is one of the most versatile microcontroller boards available, coming in a wide variety of shapes and sizes perfect for everything from blinking a few LEDs to robotics to entire home automation systems. One of its more subtle features is the ability to use its serial libraries to handle keyboard and mouse duties. While this can be used for basic HID implementations, [Nathalis] takes it a step further by using a series of Arduinos as a KVM switch; although admittedly without the video and mouse functionality yet.

To start, an Arduino Uno accepts inputs from a keyboard which handles the incoming serial signals from the keyboard. From there, two Arduino Pro Micros are attached in parallel and receive signals from the Uno to send to their respective computers. The scroll lock key, which doesn’t do much of anything in modern times except upset Excel spreadsheeting, is the toggle switch between the two outputs. Everything is standard USB HID, so it should be compatible with pretty much everything out there. All of the source code and schematics are available in the project’s repository for anyone who wants to play along at home.

Using an Arduino to emulate a USB input device doesn’t have to be all work and no play, the same basic concept can also be used to build custom gaming controllers.

43 thoughts on “KVM Uses Many Arduinos

  1. One of the two Arduino Pro Micros can easily interface with a PS/2 keyboard and mouse as well, saving one Arduino Uno. Then no soft serial is required as well. An Arduino Pro Micro should be able to emulate HID keyboard and mouse at the same time.

  2. Doesn’t KVM stand for Keyboard, Video, and Mouse?
    I would think a PiZero and a hub would be a better solution. I know the Pi can act as an HID so the question is can it do both at once. The boot up time would of course be much longer and I admit that using a full Linux system as a KVM is really silly.

  3. Really a KVM switch lacking the video and mouse is about as useful as tits on a bull. Not to mention that you can procure them for very little these days. Hell I got a used datacenter IP based KVM for $30 on eBay a couple of years ago. You run the client on any computer on the network and you have the KVM in a window at your fingertips. I also have a remote control power distribution strip that is similar, but clientless (has it’s own web based interface). With the two of them I almost never have to go into my litlte machine room.

  4. The other ones are used as USB slaves.
    And due to USB’s standard design, good luck getting one to communicate with multiple computers without having dedicated USB “drivers”.
    This approach also makes it scalable, if anything the downside is that it doesn’t accept USB in and PS/2 out.

    1. Actually it is quite easy as I have built my own KVM and have been using it for a few years. You are overthinking with all your Arduino.

      The video switching is done with $10 HDMI switch and I routed its MUX control signal to a USB MUX. The switch (with its internal firmware) can detect when a computer is on and switch the video input source to it. The USB MUX connects hub with the mouse + keyboard to the computer with the active video. The OS side handles the USB connect/disconnect. My STM8 microcontroller does very little except to monitor the PS/2 keyboard and recode the MUX control signals and


      1. The benefit of having multiple USB slaves active is that they *don’t* connect/disconnect, which can be a problem in some cases (USB enumeration/loading does take macroscopic time). A microcontroller with USB support is pretty much cost-equivalent to a USB MUX.

        1. I only need one single USB MUX for the entire project that support 3 computers. I have seen bigger MUX. It let me switch a Hub or any devices connected. If I want to switch my JTAG tool or other devices, I could simply plug it into the hub. The connect/disconnect would certainly get a bit more tricky, but I can manage that.

          There is very little coding required in my project. I could even leave my microcontroller and push the button on my HDMI switch manually.

          OP’s design needs a microcontroller per computer to act as a USB device if I read it correctly and it doesn’t let you go beyond switching the keyboard/mouse or whatever devices the microcontroller emulates.

        2. Yeah, this quickly becomes a pain in the designated posterior.
          Relying on the USB hotplug feature is like Russian roulette with windows since when you finally expect it to work flawlessly, it goes all Murphy’s law on you.
          I’ve had a situation where I had to alternate between two separate USB ports on the same computer due to Microsofts finest deciding it wouldn’t enumerate a basic keyboard or mouse on that port anymore for some time.

        3. OS handling things incorrectly means the os is at fault with USB compliance. You can’t keep fixing other’s bugs as they can still affect you in other ways. Keyboard/mouse connect/disconnect works just fine, but other devices such as memory sticks/audio devices that is still being used by os might not.

          BTW I had problems with MS USB3 drivers for Ryzen after last few win10 updates. It affects not just USB connect/disconnect, but restarting a login after an RDP session. i had to reboot the machine. It all went away after manually forcing an upgrade with AMD’s driver intended for Win7. This issue isn’t that easy to google for and it doesn’t affect any of my older PC running win10.

        4. “OS handling things incorrectly means the os is at fault with USB compliance. ”

          So you can file a bug with the OS vendor, wait years for it to be ignored… or grab three things you have lying around and work around the problem.

          A lot of hackers have the things lying around that this guy used. Almost certainly more people have these things lying around than a USB multiplexer dev board. Nothing in his setup is special purpose, which means he literally spent *nothing* on this – the entire setup can be torn down and repurposed for something totally non-USB related.

          USB is a commodity protocol, which means wacko glitches and quirks and screwy crap happens All The Time. Sometimes the most “elegant” or “simple” solution just won’t work, so you go with what does.

          The point here isn’t to say that one solution is better. It’s to say that asserting “this solution is too complex, here’s a simpler one” completely misses the forest for the trees.

      2. Slightly OT.

        > This is why I need to compile on the Computer #1 using a KVM in the demo – C compiler with LMFlex licensing doesn’t work on RDP connection. :(

        Have you tried VNC? /Tight-/UltraVNC all have mirror drivers that make working with it quite fluid(?).

  5. That’s a weird and cool project at the same time. Weird in the sense that few people would think about gathering 3 Arduino boards for the same project and I congratulate you for not having psychological inertia. It’s good weird, not bad weird.

    At the same time is cool because many times I need to exchange the wireless dongle between computer setups at my desk, each one with its own video standard, sometimes VGAxDVI and other VGAxHDMI, and I know no cheap KVM that can do both (at least nothing cheaper than the 3 arduino boards)

    1. DVI and HDMI have the same electrical signals / protocal under the hood. Because of this, you can get cheap (couple bucks) passive adapters between the 2 connectors.
      So a unit with 2 hdmi or 2 dvi would work.
      The only catch is DVI doesn’t carry sound like hdmi does.

    2. “psychological inertia” I understand that it can keep you from jumping in well said. Have you found a good way to get around “implementation block”? Usually due to perfection seeking…

  6. I guess you could make a custom keyboard with two mcus to do the same thing, but i always heard that atx power supplies shouldn’t be paralled. maybe it’s not a problem at the low current levels usb draws.

  7. I have a freebee KVM 2-way dongle-pod that uses the scroll lock key to switch everything. It was handy till those purple and blue-green PS-2’s went by the wayside along with VGA.

    With 2 USB keyboards on one computer I noticed that those 3 indicator lights scroll lock etc. both went on or off together. I took a junk USB keyboard and wired a relay and transistor to the scroll lock light and have it wired to the tuner away from the computer desk. It turned a useless key into a mute button for the radio which mixes with the computer’s sound now all at my fingertips.

    Only one problem, Linux seems to disregard the scroll lock response for the light to toggle on and off. The other two still work, so num-lock becomes mute because I rarely use it.

    1. I did exactly that using proper USB2.0 480Mbps rated MUX. These parts are made for those cellphone muxing audio and serial port onto USB connectors. Discrete MOSFET capacitance is a bit high for anything above USB1.1 speeds. I switch the hub and anything on it.

  8. I like the project. Despite all the responses that it doesn’t do V and M, it’s still creative and a lot of fun. And cool idea to choose for 3 Arduino’s.

  9. I like it! And thanks for putting the code and schematics on GitHub. And with a nice permissive MIT license, thanks again! Also thanks to the other commenter who posted his similar project. I find the Arduino one more useful for my own projects, since I have near a dozen various Arduino clones sitting around, and even more bare ATtiny and ATmega chips, so I could scavenge a few connectors and pull this together quickly in my garage without ordering a USB mux or anything else. There are a zillion ways to solve a problem, and for something not-too-important, why not use the tools you are familiar with and have on hand?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.