Read from multiple input devices

One of the cool features of USB is that using Human Interface Device (HID) you can get a new device to behave as, for example, a keyboard. You can do this now with a Teensy or an Arduino UNO (but not the FTDI-based older Arduino boards). The key is that by using the proper USB messages a device can talk to the system in a way that looks like a mouse, a keyboard, etc.

The good thing about talking like a keyboard is that applications that expect a keyboard input may be fed directly with the data from that device. This many times the case with devices like a barcode reader, that can input the scanned code to the application software as if the user was typing that number on the corresponding box of the program, which is convenient just in case the code is unreadable for any reason by the reader but not by the user (or if the barcode scanner is broken or stolen).

My current project required reading RFID codes and for that I already bought a RFID reader with I2C interface that could be used from an Arduino board. However, my only interest was to read the card ID and to feed that number into the application software on a PC. I have later found a more convenient way of doing so, that requires no firmware to written: a USB ID reader. This device behaves as a keyboard and it provides as keystrokes the sequences of numbers from the card's ID. It can easily become a data source for my registering application.

However if you want to have more than a single application running in the same computer focus problems may appear and data might be delivered to the wrong software. What was like a nice and clean way of solving the problem does come with its own set of restrictions. I was looking for a way to make sure that a certain program is reading from a certain HID device and I have found that Windows has something called Raw Input that can be used precisely for that purpose. And some sample code does not hurt either. User-mode Linux driver can be used too.


Hello, Miguel!

How can Arduino UNO act like an USB host ? I know only 2 ways to do that: using a usb shield or using an arduino mega ADK (which has MAX3421e IC USB Host). Using the latter board I managed to write a parser for my T.Flight Hotas X joystick and control five servos simultaneously (one servo per axle). I used some of this code to achieve that: Developing Arduino code for HID Joystick

Miguel Sánchez said…
Dear Brydko, I am afraid the only way an Arduino can act as USB host is by using a USB shield (I am not familiar with the second choice you mention).

But maybe the HID task is highly innefficient communication, though I guess you need it because of the joystick. (Can't you change the joystick electronics by an arduino mini pro, this way you could revert back to a simpler serial connection?).

Feel free contacting me via email.

Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

One Arduino controlling two brushless DC motors