AVR USB Joystick
This project is a USB joystick based on a simple AVR ATmega8. The ATmega8 simulates a standard USB HID device with 8 analog axis and up to 28 buttons including the Coolie hat.
The project is based on Mjoy hardware and source code made by Mindaugas Milasauskas.
Unfortunately the Mjoy homepage no longer exists at: http://www.mindaugas.com/projects/MJoy/
Other sources are http://home.versateladsl.be/verlejan/Mjoy16E.html or Google.
I have changed the hardware to ATmega8 in SMD TQFP package to increase the analog channel number from 6 to 8. I made also the required code changes to support the 2 additional channels. Unfortunately the button order on the PCB header is a bit confuse, see the button and axis assignment image for details.








You sell a mounted PCI ready to use?
Nope.
Hey, i recently discovered your site. The project seems to be more than interesting. I am a student of electronics engineering and also a fan of flight simulation.
Can you tell me if axis are stable? I mean if they dont oscilate and if joystick needs windows calibration.
Maybe you can expand your article with some more info.
Thank you very much bro, hope you reply!
Of course the axis are stable.
Calibration is needed since the readout depends on the potentiometer you connect to the analog inputs.
Fantastic update on the original! I am just getting started in microcontrollers and I though I would make this my first project. I have the 1.1 and 1.2 version source of mjoy but when trying to compile in AVR Studio 4 I get 3 errors about “Invalid redefinitions”.
Anyways, your code compiles perfectly, but I was wondering what Atmega microcontrollers it can be used with? Can it be used with any in DIP packaging? I have been having a very hard time trying to locate any Atmega8 as everyone is out of stock. The closest I could find for the chip you used is the ATMEGA8-16AU. Would that work? Sorry for the bombardment of text LOL. Any advice or direction you could provide would be MUCH appreciated.
Look for the ATmega8A as a drop in replacement. not sure if the ATmega8 is still in production.
You can use a ATmega8(A) in DIP packages too, but you need to change the schematic then since DIP and TQFP have a different pinout.
Hi,
I was wondering whether you have the board and schematic in Eagle format as well. I would like to modify them to be able to use a DIP packaged ATmega.
Thanks
Sorry, but I do not work with Eagle, so there is no schematic or board file in Eagle format available.
Hi,
I want to use the project for racing wheel controller, but unfortunately no force feedback or vibration implemented, How i modify it in order to use force feedback or vibration motor ?
Thanks a lot for your reply
You can not modify the AVR USB Joystick to use force feedback. That’s neither supported by hardware nor by software.
Hello,
has you got the Layout of the bord as a picture or something like this?
I want to built the bord an can you make a list what i need to build it?
I will update the page when back from holidays.
Hello,
I build 4 of these controllers a year ago and working fine, now when I plug in to the computer (all 4 of them) windows XP says that the USB device failed.
Is it windows updates maybe?
I tried to re-program the MCU and no problem, signature reads ok.
Also, I’m interested in the source code (assembler), but have not done much assembler programming, only c/c++. What is the best way to understand how this USB-jostick code works? I tried to follow it but there is just so much of it.
Thanks,
Sound like a problem due to an XP update to me.
Most of the assembler code deals with the USB stack. I not sure about the complete code as well just digged deep enough to extent for more analog axis and buttons.
But C code for HID devices working the same way exist already, look here: http://www.obdev.at/products/vusb/hidkeys.html
You just need do deal with the USB interface and device descriptors to make a joystick.
Hello,
can you send me the Layout as Picture with the correct mass?
That’s a 2 layer board, not sure if the layout as picture is usefull then.
What you mean with “mass”, maybe board outline dimensions?
Anyway, not earlier than two weeks since I’m in holidays.
Nice work, been looking for something just like that to make controls for a flight simulator. I’ll have to look into the code a bit more when I get the chance.
Mostly out of curiosity, how did you make your PCB’s? BatchPCB, or do you have some in-house capabilities to make them?
I do only single side PCB’s at home. Two or more layer layouts are given to a dedictated manufacturer. Usually I combine layouts from different projects to reach the minimum board size for manufacturing.
Hi,
I have built several board, and from some reason I have PCs that it’s working like a charm,while on others I get an unknown USB device message and can’t get it to work….
please advise.
Thanks
Seem to be a PC side USB problem. Just a wild guess, maybe some PCs do not support USB low speed devices any longer?
Thanks for that…
I tried now to connect it over an external USB hub, and it works this way…
Any thoughts why shouldn’t it work with the my PC’s USB internal ports?
Thanks again.
I have been researching all I could find of what’s left of the original mjoy project and it seems a lot of issue comes from variations in the USB power source. An externally powered hub cured a lot of problems for a lot of different folks. I’m gonna try using a 7805 voltage regulator and a wall wort to keep the power stable between different PC’s. Meir, I’m curious to know if your external hub is powered by a wall wort?
Thank you so much Michael for giving an older project new life! I am working on a project and desperately need some way to interface a single potentiometer as a joystick axis.
Hi Jonothan, thanks for replying.
I’m using a hub that has a power input, but I’m not plugging it, so basically you can say that this is a non powered hub.
please update on your success with the 7805 voltage regulator.
Just tried with the 7805 voltage regulator, works great.
Thanks for the help.
Hi Meir, glad it worked! I haven’t yet tried the 7805 but I have been looking at more “standard” USB circuits and made some mods to mine. I removed the 4.7k resistor and Windows 7 on a laptop recognized it as an input device but with errors. I changed the 3.3v zeners to more commonly used 3.6v zeners and the laptop picked it up right away! It is even recognized by my linux desktop. I’m still testing and refining it, as I have some problems with the pots, but I’ll post my results. Be sure to connect any unused pot inputs on the atmega to ground.
Hello
nice and interesting software to use as a Flight sim DIY joystick, I just have a question, what are the Fuses Hex codes to use this program in the ATMega 8 MC
Thank you in Advance for your Response
Regards
The ATmega8 fuses are:
High 0xDF
Low 0x3E
Hello,
any idea why I can’t build the sourcecode in AVRStudio 4.0 ?
It says: Line too long (in .aps-file).
(I’m an absolute newcomer in AVRSTudio)
Matthias
Hello great project.
It is possible to migrate this project from Atmega8 to Atmega16? I have built mJoy16 but there is not source code. Next question: is possible to merge two pots (two inputs) as result one axis Y? I need this for throttle and brake and I need this on one axis.
Porting to mega16 shouldn’t be a big deal, you just need to rebuild the code with includes for mega16.
Your poti problem seems to be more hardware related. I think you need to find a way to wire up the pots right to get the functionallity.
Hello and thank you very much for so generously publishing all of your work online!
I have assembled a USB/Analog/Joystick device, however I have followed the Mindaugas Milasauskas guide at: .flightsim.com/main/howto/mind.htm as it seemed easier and quicker to use the ATmega8 in a DIP package.
Anywaze, I am having much the same problems as many who have posted here:
My Mac sees the device as a Joystick/HID however my XP/Windows/PC will only see it as a USB, Unknown Device.
Have you been able to come to any conclusions as to a mod to the hardware or code that will allow Windows to reliably id the device?
Any further advice would be hugely appreciated and thanks again for your guidance thus far.
Dan
You may try the suggestion from Jonothan Greene in his comment above.
He changed the Zener diodes from 3.3V to 3.6V, seems it solved the problems.
Thanks Michael, I ended up trying all suggestions in this order:
-Installed a 7805 to provide discreet power.
-Installed Zener Diods between 0V and +/- Data lines.
-Removed the 4k7 Res.
I tested between each mod, but, it wasn’t until I removed the 4K7 that XP would see the device. When I tried rerouting the power back to the USB 5V line, Windows lost it again.
(My mac could still see the device regardless of each change)
I’m not sure whether the system requires all of the mods before XP will recognise the device as an HID and am still unclear as to what difference removing the 4k7 made, but for now, the thing is working, so thanks again.
I’m hoping to expand the system to include two rotary encoder inputs on some of the I/O lines.
Is that something with which you have had any experience?
Further testing has now shown that Windows will actually only see the device if it is powered with a battery (via the 7805) and not with a mains based supply (wall wort)
Has anyone else had similar findings?
I’m not sure whether the mains hum might effect the data from the AVR?
Dan, this is a late reply so you may have already worked it out, but just in case anyone else needs the information here it is – you shouldn’t need to use a 7805 voltage regular as long as you use 3.6v zener diodes and remove the 4.7k resistor. When I suggested trying a 7805 that was only for testing purposes because the original design used an incorrect method to drop the voltage on the Data lines. It will work using power from the USB, no external power should be required.
Now considering the 7805 is not necessary anymore, the only reason I can guess as to why it would only run from a battery is that your wall wort was not at least 7.5v or higher, as most standard 7805′s need at minimum 1.5v higher voltage than what it will output (5v).
Once again for clarity, you need to do both of the following:
-Use 3.6v zener diodes
-Remove 4.7k resistor
Hi
My name is Amir Rehman. I have read your article AVR USB Joystick about building a joystick. It is really a fantastic article which demonstrate the procedure very brilliantly. I am just to make a racing wheel joystick and your expertise forced me to ask you about making such joystick. I ll be thankful if you assist me how can I develop a racing wheel joystick.
Kind Regards
Amir Rehman
A racing wheel is nothing fancy. Build the mechanical part for the wheel including the potentiometer and connect it to one of the analog channel, done.
Hi Michael,
I want to develop a racing wheel using this project. Assume I have Gran Turismo 5 on PC, will this joystick be playable with this game?
Thanks
The joystick will show up as a standard USB HID device. So should work.
Another question,
If this racing wheel be compared with logitech G27 then which would be good one?
hi:
I have a lot of problems with mjoy project because when I press a button, at same time press 2 or 3 more. can somebody help me with a schematic for dip pack atmega 8a please?
I like to make exactly this project but i cant buy smd package. i´m based completely in this code version and schematic. Have somebody help me? Im loosing my head…and my job almost.
http://flightsim.com/main/howto/mind.htm this where I´m based to make the project.
See my schematic, the reason why I added all the diodes to the buttons is to prevent pressing more than one button at the same time. The diodes are missing in the original schematic.
I have 1 question about your project. I am simply looking for a usb replacement for a game port to sense contact closures (button presses) does the pc see this as a game port for software that is made to use the old style game port?
Thanks
Daryll
The interface will show up as a USB HID device. That’s not a game port.
Hi,
I’m from Czech Republic, and I am really intrested in this project. I like it, but I’m afraid that will works. I’m a little scared that I draw a scheme, make it, join it, but it will not works. I wanna ask you to sent me email with the newest versions of hex file, schematic picture, and everything what I need to build this.
I also wanna ask about version of ATmega8. Is it problem if i use ATmega8-16PU or ATmega8535-16AI? I’m afraid of programming the hex file, i know the package is different in 16PU version.
Thank you so much for your reply, BB, Martin.
All informations only are latest, including schematic and firmware.
Replacing the ATmega8 in SMD by a DIP version requires significant changes in schematic since packages have a different pin-out. The ATmega8535 can not be used.
And – you recommend to use zener diodes 3.6V rather than 3.3V?
And also big question – does it run under Win7?
Sorry I’m still anoying you, but could you make sharp (HQ) photos of the board? or send me picture of both sides, thank you.
3.3V Zener was the initial part. From experience of other users you may use 3.6V instead.
About Win7 I can’t tell you, have no computer with such OS installed.
3.3V or 3.6V I should use? You write the same values.
Hello again bro. It took me a while but i finally built one using atmega16. Only change m8define.inc for m16define.inc on Avr studio. Working perfectly except for some axis range problems… im getting 99% of range… still working on it. Diodes must be 3.6V as stated in documents.
Thanks for feedback.
Does this ATmega8 works for this circuit?
http://www.olimex.cl/product_info.php?cPath=52_74&products_id=245&product__name=ATmega8_8K_16MHZ_5V_32TQFP
Yes, will work.
Hello,
My name is Alfonso and I am working with a PS3 controller. I want to do a modding with the pad but I have a problem, I can’t use the home button, it doesn’t work. So, there is any way to emulate this button with this AVR Joystick?
Thanks
Hi,
I am going to build an Arcade Stick used mainly for Fighting – and Arcade Games.
The stick I ordered has one mass for all four directions.
If I just put the diodes on the other side of the switches will they still prevent ghost keying?
(They should, right?)
I took a short look at the code and it seems to me all buttons are enabled by default.
Considering the performance (some arcade games are pretty delay sensitive) would it be an improvement if I throw out all of the stuff I don’t need or isn’t it nessesary? (no need for analog controls)
Despire studying Electical Engeneering I really prefer asking before I order too much stuff and went into trouble.
Thanks Lothar
About the diodes you have to try, don’t know for the moment.
You can remove parts of the code, might give some improvement but I wouldn’t expect much.
Hello. I would like to ask if this device can work with operating system Windows 7. Thank you
It’s supposed to work since a standard USB HID device will be emulated. Although I didn’t test under Win7, don’t have the OS.
Sorry =)….yes, it works well under Win7