I ran into some issues tonight with my Saitek X55 HOTAS: each key press was repeated instead of showing up just once. This made the aircraft systems uncontrollable and at least once it caused my computer to lock up. I couldn’t figure out what had changed since last week when everything was fine until I realized I had just gotten my TeamSpeak setup up and running again.
At least one forum post had mentioned multiple key presses from the X55 when the TeamSpeak client is running. To get around this issue you can either:
- Not use TeamSpeak; not really an option for online gaming
- Instruct the client to read only keyboard and mouse inputs and ignore any other devices
To instruct the TeamSpeak client to use only keyboard and mouse inputs:
- Open the TeamSpeak client
- Go to “Settings -> Options”
- In the Options dialogue select “Hotkeys”
- In the drop down box at the bottom right of the window select “Keyboard & Mouse Only”
- Click “OK” to exit
In the first part of this series I explained what software and hardware you will need to get started with flashing your Arduino board so that it can emulate other devices. In this post I’ll show you how to do it. Please note that while I’ve done this many times successfully, there is always the chance that something may go wrong. I am willing to help but I can take no responsibility if the steps below render your Arduino board unusable.
At the end of the post you will find a list of sources I followed to compile the information for this series.
What will happen?
There are two Atmel chips on the Arduino board: one controls the communication to the computer while the other runs your code (Atmega16U2 and Atmega328P, respectively, on the board that I am using). To emulate a USB device the 16U2 needs to be configured to identify itself as the desired device and this is achieved by flashing it with firmware which is similar to what is written to the Arduino board when you upload your Sketch.
The larger (328P in my case) chip will handle all the logic and reading of inputs while the 16U2 will pass these inputs to the computer as the device it emulates, a keyboard for example.
To develop new functionality for your USB device you will have to alter your development flow to account for the flashing of the 16U2. Whereas the normal development steps when working with an Arduino are:
- Write sketch
when your Arduino is emulating a USB device the steps become:
- Write sketch
- Reset 16U2 (put in Device Firmware Update (DFU) mode)
- Flash device firmware
- Disconnect and reconnect
The last three steps are also used to recover the Arduino so that you can upload more sketches to it:
- Put device in DFU mode
- Flash Arduino firmware
- Disconnect and reconnect
You will need:
- Arduino board
- Header jumper (or wire to connect between two headers)
- USB cable
- Atmel FLIP USB drivers (if on Windows)
To enter DFU mode:
- Connect the board to the computer and make sure it is on
- With the header jumpers or wire, connect the two headers closest to the USB cable (in red below) and keep connected for one second then remove the jumper. The board will flash and the Arduino COM port will disappear from the Arduino IDE. To recover at this point simply disconnect and reconnect the USB cable to power cycle the Arduino.
You are now in DFU mode. You will not be able to upload sketches to your Arduino any more at this point. To be able to communicate with the Atmega16U2 chip you have to install some drivers. To do this in a Windows environment follow the steps below.
- Open Device Manager on Windows and search for an unkown device.
- Right click the device and select “Update Drive Software…”
- Select “Browse my computer for driver software”
- Navigate to the usb folder in the Atmel FLIP installation folder (C:\Program Files (x86)\Atmel\Flip 3.4.7\usb normally)
- Select the file “atmel_usb_dfu.inf” to be installed
You are now ready to flash the Atmega’s firmware.
Flashing the firmware
As a test, and to show you how to make your Arduino usable as an Arduino again we will first upload the official Arduino firmware. You will need all of the above plus
- Atmel FLIP software
- Arduino firmware (in the first example I am using the file Arduino-usbserial-atmega16u2-Uno-Rev3.hex from the Arduino github)
With the Arduino in DFU mode and the drivers installed:
- Start the Atmel FLIP software. You will be presented with the window below.
- Load the HEX file you wish to use by going to “File -> Load HEX file”.
- Select the target device by going to “Device -> Select…” and choosing the model of chip, Atmega16U2 in my case.
- Connect to the board by going to “Settings -> Communication -> USB” then selecting “Open”. The options in the Atmel FLIP window will now be enabled and you are ready to upload the firmware.
- Click on “Run” and wait for the firmware to be loaded. The circles next to the options checked will turn green.
- At this point you can either disconnect and reconnect the board the the computer (power cycle it) or click on “Start Application” with the “Reset” option checked.
If you chose the Arduino firmware you will see the COM port reappear in device manager. If you’ve loaded another device’s firmware look for that device in device manager. If you run into any problems, double check that the device is in DFU mode or that you’ve selected the appropriate target device in FLIP.
Leave your comments and questions below and I hope you enjoyed this tutorial!
To write this series I referred to the follow sites:
The Arduino platform is quite useful for making a quick prototype or when you’re getting started with embedded programming as a hobby. There are a number of shields available to extend a board’s capabilities but there is also a lot that can be done without any extra peripherals.
In this series I will demonstrate how you can flash the Arduino Uno with new firmware and have it emulate another type of device belonging to the USB Human Interface Device class (i.e. keyboard, mouse, joystick and so on). Using this knowledge (and the tools mentioned below) you too can create your very own input device be it a keyboard, joystick or even something like Hak5’s Rubber Ducky.
I will cover:
- What software and hardware is required
- How to use the software in a Windows 7 64-bit environment (should be the same in other versions of Windows as well)
- Resources for firmware
- What to do when things go wrong
I will be using an Arduino Uno R3 (non-SMD) which features an Atmega16U2 (small chip by the USB connection) and Atmega 328P (larger chip). The steps below may vary if your board is different but the process overall will be approximately the same. I would strongly encourage you to read through to the end of the article before connecting your board and following the steps to decrease the risks to your sanity (and Arduino board).
This first post will get you all set up with the software and hardware you will need. Let’s get started!
You will need
This tutorial’s aim is to give you an idea of the process which you will need to follow to be able to flash your Arduino with new firmware. As your projects develop you will find you require more hardware (and possibly software) than is mentioned below.
- Arduino board (I am using an Arduino Uno R3)
- USB Cable (to connect your board to the computer)
- Header jumper (or wire to connect two headers)
- Arduino IDE (install from from Arduino.cc)
- DFU Programmer
- Windows: install from Atmel FLIP
sudo apt-get install dfu-programmer
- Arduino firmware (so you can restore your board to function as an Arduino)
- Firmware for the device you want to emulate; some examples here
- Arduino sketch with the logic for your peripheral (you can skip this for this tutorial
The next post in this series will cover flashing your Arduino board with the new firmware.