Atmega328p VUSB Gameboy Zero or Arcade Controller
Using this USB device was only tested on a raspberry pi B with Retropie
required hardware:
- arduino nano, leonardo or at least something with an Atmega328p chip on it
- two zener diodes 3v6, two 68r resistors, one 2.2k resistor (I actually used an 1.5k resistor)
Note you need to:
- use version 1.0.5 of the arduino IDE which you can find at: https://www.arduino.cc/en/Main/OldSoftwareReleases#1.0.x
- after you install the IDE go to the libraries folder and add the files from this repository (located under libraries)
- pins 2,4 and 5 are used for USB communications (D2, D4, D5 on a Arduino Nano V3) see schematic.jpg
- solder the diodes and resitors to D2, D4 and D5 as shown in the schematic
- pins 14,15,16,17 are actually analog pins(A0,A1,A2,A3), but the can be used as digital inputs as well
- this software is pull-up, so your buttons should go to ground (not 5V or else). Use a common ground.
The pin setup for the keys is as follows:
define NUMBER_OF_KEYS 15
char pinCharacters[NUMBER_OF_KEYS] = { KEY_ENTER,KEY_RIGHT_SHIFT,KEY_Z,KEY_X,KEY_A,KEY_S,KEY_ARROW_UP,KEY_ARROW_DOWN,KEY_ARROW_LEFT,KEY_ARROW_RIGHT,KEY_K,KEY_Q,KEY_W,KEY_E,KEY_R};
int pinButton[NUMBER_OF_KEYS] = { 0,1,3,6,7,8,9,10,11,12,13,14,15,16,17};
meaning:
pin0 : KEY_ENTER
pin1 : KEY_RIGHT_SHIFT
pin3 : KEY_Z
pin6 : KEY_X
pin7 : KEY_A
pin8 : KEY_S
pin9 : KEY_ARROW_UP
pin10 : KEY_ARROW_DOWN
pin11 : KEY_ARROW_LEFT
pin12 : KEY_ARROW_RIGHT
pin13 : KEY_K
pin14 : KEY_Q
pin15 : KEY_W
pin16 : KEY_E
pin17 : KEY_R
This should give you enough buttons to emulate for d-pad, buttons a,b,x,y and shoulder buttons l1, l2, r1, r2 (and one to spare....perhaps for sending an escape character)
If you use this software, make sure that:
- you solder your keys / buttons to the proper input (as mentioned above) OR
- change the above code to match your own soldering.....keeping in mind that by default pins D2,D4 and D5 are used for USB communication
- if you want to change the used pins for USB check usbconfig.h (USB_CFG_DMINUS_BIT, USB_CFG_DPLUS_BIT and USB_CFG_PULLUP_BIT)