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.
I noticed from the source code that it looks like the actual keyboard is expected to run in PS/2 mode, so the Data – / + labels are a bit incorrect.
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.
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.
FYI: My KVM project switches HDMI video, USB for mouse + keyboard. I use a $10 HDMI switch + PS/2 to USB for keyboard, a USB MUX and a single STM8 micrcontroller.
https://github.com/FPGA-Computer/KVM-Switch
I would imagine he is planning on adding those features later. If he just wanted to switch the keyboard he could have used a single double pole double throw switch. Before anyone tells me you have to switch the power and not just the data lines read this. https://hackaday.com/2016/11/12/diy-kvm-switch-lets-you-use-one-keyboard-and-mouse-with-multiple-computers/
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.
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.
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
https://github.com/FPGA-Computer/KVM-Switch
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.
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.
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.
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.
“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.
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(?).
They now moved to an automated system probably due to the volume of requests. I just get more of the “free” compiler licenses for my computers. ;)
I haven’t touch VNC for a long time as I like RDP.
Give me 3 arduinos over an FPGA any day of the week!
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)
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.
Monitors with multiple video sources could have easily functioned as a cheap KVM if they also had a USB MUX inside.
“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…
Hey man. Being genuine here, but feel free to not comment on projects you don’t like.
Feel free not to comment on comments you don’t like. The real problem here as often happens is the title: it’s not a “KVM” it’s a “K”.
Imagine having so much time and anger that you rage post about someone else’s hobby.
Build a company like Microsoft and then comment like you did…
a pile of arduinos is quite easy to turn back into a pile of arduinos
Bill I think the site you’re looking for is AliExpress not Hackaday. Sheeze.
Bill I think the site you’re looking for is AliExpress not Hackaday. Sheeze
That’s expensive..?
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.
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.
Wouldn’t it be a lot easier to switch the D+/D- USB lines using suitably high speed MOSFETs?
Easier, yes, but waiting for the USB keyboard to be detected and properly configured each time you switch would probably drive the user crazy.
For a KVM with video capability by the time the monitor syncs after a switch in video source, the configuration is over. ;)
Didn’t think of that. Last time I used KVM it was a metal box with an analogue switch. I though that with HDMI and DIsplayPort things got more civilized. Silly me ;-)
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.
Ahhhh, the old HaD censorship two-step.
??
Or use 2x ESP8266 with espusb:
https://github.com/cnlohr/espusb
It behaves as an HID keyboard:
https://www.youtube.com/watch?v=tz7tK7O42Tw
Switching between one or the other might be just connecting to another IP address.
“using a series of Arduinos as a KVM switch; although admittedly without the video and mouse functionality yet.”
So it’s a K switch then.
Scroll lock stops your terminal from scrolling
This is just a K, not a KVM – no video, no mouse, no use.
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.
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?