Introduction: Connect Arduino UNO to USB Keyboard

About: DIY my way through life. For me, Instructales is a way of living. It's my making log. My life is counted with the instructables I make. Visit my website and If you need more Arduino Mentoring for your class yo…

The actual sit and write is the essence of being a writer. Just as in any other discipline, if you do not invest time, mind and effort in doing it, you are treating it to be just a hobby.

The mind you give to the process of writing comes back to you in a form of the Flow. The process of effortlessly create something valuable with ease and timelessness. It’s well known that whatever habit that you devote yourself to is what you can be finally rewarded for.

That's why I've wanted to make this project to concentrate on the process of writing itself.

Here is my Channel on Youtube:


Please Subscribe.

Step 1: The Story

Today I’m showing you how I’ve made this new project. Of course, it’s about Arduino and it’s about writing.

For some reason I wanted to connect Arduino to my keyboard.

Because I love writing on the keyboard.

It’s that real physical feeling of switches on my fingertips that makes me feeling creative and alive.

But there’s only a small problem. My favorite keyboard is happened to a USB keyboard.

Yes that’s the new modern technology is about and it’s something I should be happy with.

But the only problem I was having when I wanted to connect my keyboard to Arduino (as a host to my keyboard) I found that the standard use of Arduino with a keyboard is the PS2 connection.

Actually there is a good well written Arduino library for this purpose.

So how could I connect my USB keyboard to Arduino? I only remembered back then when I was looking for a keyboard for my notebook (which had no PS2 ports in it) is that I wanted to figure out some way to use a PS2 keyboard with a USB port but I couldn’t found this.

And that’s why I bought the USB keyboard for the first place.

But this search has helped me a lot these days when I wanted to connect my USB keyboard to Arduino.

I only then remembered that although I couldn’t use a normal PS2 keyboard with a USB port in a notebook because of the different protocol, but the opposite is doable.

I remembered that I’ve found an instructable that described building a USB to PS2 converter.

The writer mentioned that he has tried it and it worked.

This means that you can use a modern USB keyboard with your old PCs and laptops using only this converter.

It’s just a physical converter for the connection between the keyboard and the host port(not a voltage or protocol converter). That’s because the USB keyboard can be powered from the old PS2 port, take the CLOCK signal from it and then send DATA signal to it.

And the writer has tried to make this setup and it worked. Now it was my turn. When I looked for some information to connect a USB to an Arduino board I found that in order to do this I need either an Arduino USB shield or an Arduino board with Microcontroller that have the native USB host physical feature. Neither option were available to me.

So I’ve decided to try the physical USB to PS2 converter - the writer has tried with his PC - between my USB keyboard and Arduino. You know what? This one also worked.

Using the PS2 Arduino library we can connect the USB keyboard directly to Arduino boards such as Arduino UNO or Arduino Mini.

Step 2: The USB Female Port

I had that female USB connector but I had to first test its pin-out with a voltmeter.

Then I made a cross connection between the USB connector and the PS2 keyboard of the library.

USB Keyboard PS2 Port

+5 v Vcc +5 v Vcc

Data- Data

Data+ Clock


Step 3: Circuit Connection


Arduino UNOBanggood , eBay

Female USB port


USBPort Arduino

+5 v Vcc +5 v Vcc

Data- PIN 2

Data+ PIN 3


Step 4: Software

Download and save the latest Arduino PS2 library from here.

Open Arduino IDE.

On the sketch menu, select library. Add Zip file.

Point to the Arduino PS2 library Zip file location and then press Enter.

On the File menu select examples.

From PS2keyboard sub-menu select International.

You find the international.ino sketch loaded into the Arduino IDE.

Edit these two lines of code


const int DataPin = 8 ;

const int IRQpin = 5 ;

In this case, I used

DataPin to be Arduino Pin 2


IRQpin to be Arduino Pin 3

Step 5: Test the Project

Open the Serial Monitor and watch try the keyboard as you wish.


There will be a different response from some keys on the keyboard.

This is caused by difference of Arduino response to the keyboard than the standard PC.