Close
0%
0%

Arduino K(V)M Switch

A modular, expandable Keyboard & Mouse switch using Arduinos

Similar projects worth following
Having used KVM switches at work for a few years I have been looking for a cheap and expandable KVM that can grow as my collection of machines grow; every time I get a KVM that can do the job another computer comes my way!
At present most of my machines have their own monitors so video switching is not a priority just yet; I will be therefore focusing on the Keyboard and Mouse switching for now.

This is the plan. I say plan... See it more as a brainfart that requires ALOT of actual thought:

An Arduino Uno will receive input from the Keyboard/Mouse (either using Host Shield or using PS/2 Devices and the PS/2 library.

The Uno will also act as an i2c master.

An Arduino Pro Micro clone (based on the Atmega32u4 chip) will be added as a slave for each Machine that needs controlling.

Each slave will carry the code to provide key strokes for all platforms (Win, Mac, Android etc plus custom). A switch added to the slave can determine mode.

The master will monitor the PS2 inputs and redirect the keystokes and mouse data to the relative slave when a key combo is entered; The Pro Micros will be recognised as HID devices and pass the received input to the machine.

In order to make this modular I am keen to design a case that features a backplane of sorts that carries the i2c lines, and then the Pro Micros can be connected by simply plugging into this backplane. This will all the switch to be easily expandable.

  • 1 × Arduino Uno I2c master & keyboard/mouse reading
  • 4 × Arduino Pro Micro Atmega 32u4 I2c slaves & keyboard/mouse sendiing for machines
  • 2 × 1.5K-47K Resistors To pull up SDA & SCL to 5v

  • Oooooh!

    Craig Hissett04/08/2016 at 06:28 0 comments

    Ive just stumbled on something to help massively with the software for this:

    http://www.instructables.com/id/Bluetooth-Keyboard-Mouse-Adapter

    This uses an arduino to read PS/2 keyboard and mouse input and sends it straight to a Bluetooth HID dongle for sending to a connected device.

    I can use this code as a platform to handle the keyboard and mouse input capture, then modify the output to send to i2c rather than serial.

    Yay!

  • More Thought

    Craig Hissett03/15/2016 at 21:19 0 comments

    while this project is currently shelved as it were, I have been having the urge to get at least a working prototype up and running. You know, just to see if it works.

    Having a self diagnosed inability to knock up hardware has always stifled my projects; they really take off once I have something to code and program, but getting there? Jesus!

    I found a small sheet of perfboard in my cupboard today; not my usual stuff I get with all individual holes, the stuff with tracks along it. Didn't even know I had it!

    This has given me an idea.

    Using this I can great the plane for my arduinos to plug into and link all the i2c pins together. A 4pin head attached at one end would allow for the master arduino to be connected simply, then a series of female headers will be used to attach the pro micro boards the the plane. Tracks could be cut to allow other pins to be broken off the headers, and header pins removed to stop any other arduino pin being connected to the i2c lines.

    I need to find some female header pins but when I do I will give it a go!

  • Hmmm: A thought for Video switching

    Craig Hissett11/08/2015 at 21:14 0 comments

    It's Sunday night here, and I am lying watch Expendables 2 with the boy, kind of half-thinking about work tomorrow.l, and something has just struck me...

    There has been a spate of office moves and relocations at work, and a few weeks ago one of my colleagues left an archane VGA splitter box on my desk.

    It is one in, two out, but... what if I was to remove one of the outputs and wire it as an additional input and use the master Arduino to switch which port the splitter receives data from???

    Answers on a postcard please :)

  • Project on Hold

    Craig Hissett10/23/2015 at 00:27 0 comments

    Just a quick update to ket you all know this project is being shelved for the moment while i work on some other projects.

    I shall be using some of the components in another project for the time being and will be re-ordering parts when I return to this one.

    I have the code pretty much finished for this one (sketches for the master and slave arduinos) as well as more detailed plans of the build; these will be shared with you very soon.

    If anyone would like to take this project on further with my material please let me know and I will happily invite you to collaborate.

    Cheers!

  • Updates: Coming soon!

    Craig Hissett09/13/2015 at 00:16 0 comments

    Just a quick note to say that this week should see the completion of my other project (a raspberry Pi-based Video Player for my son). Once this is complete I will get some real work done on this project!

    I am looking to use this as soon as I get it up and running. I have two little netbooks (one for development, one for media stuff) that i would like to put in a case with a mouse and keyboard. I would also like to have a couple of extra ports for connecting Raspberry Pis and whatnot.

    Im open to suggestions for a case design too. As long as it has a bay for the Arduino Uno and a shield, some slots for thr pro micros and a 4-line backplane with a 4 pin male/female header at each bay its all good :-)

  • Testing - and extra ideas!

    Craig Hissett07/02/2015 at 16:40 0 comments

    So...

    I have finally got my hands on a Pro Micro to start playing with (I got impatient so pulled this one out of an old project (a keyboard emulating foot controller for music recording), and will start coding the slave and some of the master tomorrow :-)

    For the master Uno I have opted for a clone. Partly due to a love for it's colour (ha ha), but mostly because it has a micro USB port rather than the Printer-style USB. This way the end user is able to program the master using the same cable as the slave is connected to the target with.

    I have had an idea for a further use for the master - I often use a small netbook for coding and suchlike, and it would be great to use it's keyboard as an input to other devices when quickly prototyping.

    My idea is to use the serial input on the master as an alternative to the keyboard/mouse inputs on the board.

    Up until now in my heads the master's USB port will grant the user with a serial menu to configure the KM switch in a variety of ways. I now plan on adding a menu option to allow 'through-typing' - anything typed into the serial window while in that mode will be passed to the selected slave as in normal use. a pre-defined keyboard shortcut would end this mode.

  • Research

    Craig Hissett06/28/2015 at 01:30 0 comments

    I have been looking at various sources looking for ideas to incorporate into my project.

    I am breaking my research into 4 areas; getting keystrokes/mouse movements into the master arduino, getting the keystrokes/mouse movements Out to the slave, receiving the output on the slave, and sending that out to the target machine.

    I have briefly used i2c communication before and have used an Atmega32u4 for keyboard output in the past so I am focusing on how to read PS2 input I have attached a link to a fantastic project which creates a DIY shield for an Uno.

    It also states that this shield should still work if USB>PS2 adaptors are used, so i may build them into my final design. USB keyboards are much more common these days.

View all 7 project logs

Enjoy this project?

Share

Discussions

gir wrote 01/14/2017 at 15:03 point

Some input about video switching: 

I've built an 12 port RGB switch box + HomeCinema automation device for my retro video game collection a few years ago, using the NXP CBT3244A (I thing I used a TI variant of it IIRC) and 74595 shift registers.

I got the idea from [this BenHeck article](https://www.engadget.com/2007/03/13/how-to-make-a-solid-state-a-v-switcher/). 

It should be trivial to add one of those chips to each of the Micros, or wire the USB / PS/2 bus into it as well and drop the Micros completely.

Hit me up, if you want to know more about anything I mentioned above.

(Maybe it helps someone else, if Craig doesn't want to / can't develop this thing further)

  Are you sure? yes | no

Craig Hissett wrote 01/14/2017 at 15:55 point

That's some amazing information,  thanks man!

I will definitely look at adding those to the pro micro modules.

Going to be picking this up again very soon so I'll be in touch!

  Are you sure? yes | no

kgbuck wrote 08/03/2015 at 13:43 point

I love the idea and as a PC technician for years I can see it would be great to have such an easily and cheaply upgrade-able system. I do note however that you are looking at PS2. I am sure you must be aware that hardly any systems use PS2 any more, USB HIDs are the default now. Is there some reason you are using this?

  Are you sure? yes | no

Craig Hissett wrote 08/03/2015 at 14:06 point

Thanks kgbuck! Yeah, the ability to expand it is what i love - plus each channel will only cost a few quid a channel :-)

The reason I am aiming for PS2 input at first is for ease; there are some solid libraries that I know work for it. While archaic i was going to take advantage of most USB peripherals's backwards compatibility and use some USB>PS2 adaptors for now.

The output is fully USB HID thougj, using the arduino pro micros.

Dont worry, i will eventually aim to upgrade it to full USB for input when i understand it :-)

  Are you sure? yes | no

kgbuck wrote 08/04/2015 at 08:47 point

Thanks Craig. I figured there would be a reason but I am new to Arduino so that is why I wondered. It makes sense to start with what you know works. I will be following with great interest. As a side point, while I understand why you are starting with input only, the potential to be able to control computers in a different room through a few wires would reinvent the principal of the KVM.

  Are you sure? yes | no

Craig Hissett wrote 08/04/2015 at 10:28 point

Ah, arduinos are great; especially as platform for getting into this hobby of ours :-)

Yeah the PS2 library looks as though I'd be able to accept input from a keyboard and mouse, whereas I am unsure about USB Host capabilities. There are libraries and shields available for the Arduino which look great, but only feature one USB port. I can't find anything concrete to support whether you can hub that port and use two devices through it, or add a second port etc.

For now though I should be able to replicate that USB input with the PS2 code and adaptors, but will still hope to upgrade in the future.

The output for the Pro Micro arduinos is pretty straight forward; still and monitor the i2c line for anything coming through marked for its address, and forward it straight out of its serial port (its micro USB). The ATMega32u4 chip is recognised as a HID so it will operate as desired without any extra work :-)

As for your multiroom control idea it could be done (please indulge me here, I'm thinking out loud :-) :

You could use a pair of esp8266 wifi transceivers; they can be written to and controlled by I2c and arduinos, I believe. You could insert one esp8266 in the KVM in place of the the pro micro and configure it to send anything coming to to the other esp8266. This second esp8266 and the pro micro could be put together like a dongle, and inserted into the target PC, relaying any keystrokes and mouse movements to the target.

I'd probably need to figure out the video part for that to be useful though :-)

  Are you sure? yes | no

frankstripod wrote 07/01/2015 at 07:53 point

I can't wait to see this work :)

  Are you sure? yes | no

Craig Hissett wrote 07/01/2015 at 08:11 point

Thanks man! Just waiting for my pro micro slaves to arrive from China before i crack on coding :-)

I cant wait to have a KM switch that I can expand for £3.50 per channel ha ha!

  Are you sure? yes | no

frankstripod wrote 07/01/2015 at 08:41 point

I like the backplane/case idea.

  Are you sure? yes | no

Craig Hissett wrote 07/01/2015 at 09:29 point

Ah, i can't wait to get around to putting ideas together for the case.

The backplane idea goes really well with i2c; if I run the 4 required communal connections through the back of the case then i am free to plug in the slaves in a variety of configurations.

This will allow me to make it truly modular and also leave the design open to expansion; there's no reason why other devices can't be connected to be controlled by the master :-)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates