Professional Documents
Culture Documents
I've heard a lot of people saying that arduinos are great interfaces for creating elaborate sim cockpits, but the dudes saying that are the
ones who already have an aptitude for programming. I have not seen any of them share a turnkey solution using an arduino to make a
cheap joystick encoder suitable for a sim pit. I know, because I've looked for such a thing and never found one. All the sim pit builders
who have used arduinos have never shared the details of how exactly they used one.
A previous solution that I had high hopes for described how to turn an arduino into a HID
joystick, but it only worked for the UNO and only provided one button and 2 axes, and of
course was missing the oh-so-important sketch (program that runs on the arduino) that makes
it all work. I guess they just assume that anyone willing to buy an arduino was also willing to
dive headlong into an oddyssey of countless hours learning C+, C#, or Processing language to
program their own sketches that poll each pin and perfectly pass it to the USB file descriptor
function. Example sketches based on that code were never fully functional had NEVER had
any comments in the code describing how it worked making it near impossible for someone
without a programming background to use.
After months of disappointment trying to figure out the HID joystick example code and learn
what the hell bitshift, pointers, and dereference operators were, an easy solution came to my
rescue. It's called Megajoy, which is based off of Unojoy code that allows you to turn an
Arduino UNO into a working joystick, complete with the sketch. With the purchase of a
cheap Arduino Mega that you can get shipped from China off Ebay for like $18, you can
easily build a 12 analog axis, 64 button joystick interface that you can use to build a CDU,
UFC, a bunch of panels, whatever you want. Anyway, lets get started:
The one I got is an Arduino Mega 2560. An arduino is just a brand name
for a line of Italian circuit boards that have a programmable chip in the
middle and the crystal it uses for timing, along with other features such as
easy-to-connect pin headers, power, and a
way to connect it to the computer. On
my Arduino Mega 2560, the chip in the
middle that makes up the brains is
stamped with "ATMEGA2560 16AU
1126" and it has a USB-B connector, a
DC-in jack, 53 digital pins, 16 analog
pins, and a bunch more other stuff that I
don't know what it does. I got mine off of Ebay for $18. Mine is not one of the newer "R3"ones that
have a combined DFU and USB Serial firmware, so I don't know if those R3s will work with
Megajoy or not.
Here's some current auctions selling what I have for around $18:
http://www.ebay.com/sch/i.html?_sacat=0&_nkw=mega+2560&_frs=1
http://www.ebay.com/itm/New-Mega-2560-ATmega2560-16AU-Board-Arduino-compatible-/300841945511
http://www.ebay.com/itm/New-Nice-1PCS-ATmega2560-16AU-Board-with-USB-Cable-For-ARDUINOs-IDE-MEGA-2560-
/170930838194
Once it does this go to Device Manger (Hit Windows Key + R, then type in
devmgmt.msc and hit enter) and locate the "Arduino Mega 2560" with the
yellow exclamation point and right click and "Update Driver".
Click "Browse my computer for driver software" Point it to find the driver at: E:\Program
Files (x86)\arduino-1.0.3\drivers, or wherever you put it.
Click File > Open, navigate to the MegaJoy folder and open
"MegaJoyArduinoSample.ino". Hit the arrow to upload that sucker. Once you're done
you can close Arduino.exe and move on to the next step.
As soon as the arduino goes into DFU mode you will hear the "de-dunk" sound as the arduino device disappears, then you'll hear the
"du-dink" sound as a new device appears, the Arduino Mega DFU device.
Step 10: Launch the Flip software and tell it what kind of arduino you
have:
Before the Flip software can reprogram your chip you have to tell it exactly
which atmel chip you have. This is usually what it shows up as in device
manager when in DFU mode. Mine shows up as an at90usb82 device. To do
this click Device > Select...
Then select at90usb82 from the list, or whichever chipset is on your arduino
At this point you can pretty much read and write to and from that little atmel chip on
your arduino using the Flip software. Why don't you take this opportunity to backup
and save that firmware? You can do so by clicking the USB icon then clicking
"Open"icon to make that connection to the device. 7th from the left that reads "Read
Target Device Memory". Save the resultant file as backup.bin somewhere.
This isn't necessary however since you can always restore the regular arduino firmware at
any time. The bins to do this are easily downloaded. I think the default firmware is called
Arduino-usbserial-mega.hex and is sitting in the E:\Program Files (x86)\arduino-
1.0.3\hardware\arduino\firmwares\atmegaxxu2\arduino-usbserial folder.
To do this just run the "E:\Program Files (x86)\arduino-1.0.3\MegaJoy\MegaJoy - Attack!.bat" file and it will do all the work for you
flashing the firmware using Flip.
Here is the output after running the "MegaJoy - Attack!.command" batch file:
Abracadabra!
Attempting to re-flash for an Arduino Uno R1/R2
You'll notice the communication light on the device flashing several times per second as it sends USB descriptor information through
the USB port to the computer.
Each digital button is "pulled up" meaning each pin on the device has a charge of +5v and will register that a button has been pressed
when it sees that it has been "pulled low" to 0v. What this means is you wire one side of each button to the arduino's ground pin and
the other side to one of the digital pins which is internally pulled high with a 5v signal. Pressing the button connects the digital pin to
ground pin dropping the voltage to 0v and registering as a button push. Practice grounding digial button pins with a piece of wire by
connecting one side to the ground pin and the other to each digital pin and watch as the buttons light up in the joystick properties page.
Note that button 12 on the first UnoJoy joystick is showing as constantly pressed because it's actually pin 13, which shares its
connection with an LED that is constantly lit. Perhaps you can setup its button to a normally closed switch, or ignore it altogether (or
if you're some kind of goddam programming genius reprogram the sketch and reupload it.)
For analog pins I'm pretty sure you connect one leg of a potentiometer to ground, one leg to +5v, and another pin to the analog pin. I
still have to play with this a bit but it shouldn't be too hard.
If you want to make changes to the running sketch you have to put the device back into DFU mode by shorting the pad and shorting
the reset pins, then using Flip to write the MEGA-dfu_and_usbserial_combined.hex back to the device.
And this is where the journey ends for now. This is as far as I've gotten myself, but it should be a pretty easy operation to wire up a
control panel now.
If you have any questions, come over to http://reddit.com/r/hoggit or http://webchat.freenode.net/?channels=hoggit and ask away!