{"id":611,"date":"2018-03-24T01:37:38","date_gmt":"2018-03-24T01:37:38","guid":{"rendered":"http:\/\/pcbjunkie.net\/?page_id=611"},"modified":"2020-10-21T14:16:59","modified_gmt":"2020-10-21T14:16:59","slug":"arduino-genesis-controller-interface","status":"publish","type":"page","link":"https:\/\/pcbjunkie.net\/index.php\/guides\/arduino-genesis-controller-interface\/","title":{"rendered":"Arduino Genesis Controller Interface"},"content":{"rendered":"<p>I created this for the super gun project that I just recently completed. It uses an arduino, one for each controller to decode the Sega Genesis controller protocol and interface the controls to an arcade game.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-618\" src=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/arduino-supergun2.png\" alt=\"\" width=\"921\" height=\"502\" \/><\/p>\n<p>You can see them buried behind all the wires in this photo.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-617\" src=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/arduino-supergun.png\" alt=\"\" width=\"952\" height=\"530\" \/><\/p>\n<p>This is for an arduino nano developed with the arduino platform, but I don&#8217;t see why it wouldn&#8217;t work on the mega or even clones. The code is extremely simple and should take no effort to understand and modify.<\/p>\n<p>Eventually this led me to the development of the modular supergun component. Here&#8217;s the new Sega Genesis controller interface.<\/p>\n<figure id=\"attachment_33853\" aria-describedby=\"caption-attachment-33853\" style=\"width: 1495px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-33853\" src=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2020\/10\/db9_controller_front.jpg\" alt=\"\" width=\"1495\" height=\"996\" \/><figcaption id=\"caption-attachment-33853\" class=\"wp-caption-text\">Genesis DB9 Controller Interface<\/figcaption><\/figure>\n<p>\u00a0<\/p>\n<p>You can use this to interface to any other device that requires controller inputs and has individual logic inputs for each control.<\/p>\n<p>First let&#8217;s provide the download link and then I&#8217;ll explain how to use this for your own project.<\/p>\n<p>For 3 button controllers :<\/p>\n<ul>\n<li><a href=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/sega3button-nopullups.zip\">sega3button-nopullups<\/a><\/li>\n<li><a href=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/sega3button-pullups.zip\">sega3button-pullups<\/a><\/li>\n<\/ul>\n<p>For 6 button controllers<\/p>\n<ul>\n<li><a href=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/sega6button-nopullups.zip\">sega6button-nopullups<\/a><\/li>\n<li><a href=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/sega6button-pullups.zip\">sega6button-pullups<\/a><\/li>\n<li><a href=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/sega6button-pullups-sf2.zip\">sega6button-pullups-sf2<\/a><\/li>\n<\/ul>\n<p>The files are for either the 3 button controllers or 6 button controllers. The code is not compatible across controller types, so if you&#8217;re planning to use a 3 button controller stick with the 3 button code and vice versa.<\/p>\n<p>Also, the code differs slightly whether you&#8217;re using a target with has pull-up resistors or not.<\/p>\n<p>For example, in an arcade game, pull-up resistors are used so the input pin is usually kept high until it is brought low by closing the switch or button which is connected to ground. In those cases you&#8217;d want to use the pull-up version of the code which keeps the Arduino output high impedance (set to input mode), and only when the controller button is pressed, the output pin is switched to output and set to a 0. This keeps both output of the Arduino happy in case there are any disagreements with the target device, and can avoid problems if your target is not TTL-level compatible.<\/p>\n<p>If you are using a target device that doesn&#8217;t have pull-ups, please use the nopullups version. Using pullups version of the code on such device will trigger erratic random button presses.<\/p>\n<p>The pullup version of the code is the one to use first if you&#8217;re unsure of what your got.<\/p>\n<p>Finally, for the 6 button controller, there is a version with alternate button mapping which follows the street fighter layour, so that the top buttons (X, Y, Z not A, B, C) are mapped to button 1, 2 and 3.<\/p>\n<p>Now, let&#8217;s get to how you can use this for your project. First you should wire the controller port to the arduino as follows:<\/p>\n<pre>\/\/ Controller Pin Function\n\/\/ Looking at the male socket on console \n\/\/ (front view, not solder side)\n\/\/\n\/\/ .---------------------------------.\n\/\/ \\    [A0] [A1] [A2] [A3] [+5V]   \/\n\/\/  \\     [A4] [D13] [GND] [A5]    \/\n\/\/   '----------------------------'<\/pre>\n<p>If this isn&#8217;t what you want you will have to modify the following section in the code:<\/p>\n<pre>const int PIN_SELECT = 13;\n\nconst int PIN_IN_UP = A0;\nconst int PIN_IN_DOWN = A1;\nconst int PIN_IN_LEFT = A2;\nconst int PIN_IN_RIGHT = A3;\nconst int PIN_IN_BTN_B_A = A4;\nconst int PIN_IN_BTN_C_START = A5;\n\n<\/pre>\n<p>Finally plug your target device (arcade game or whatever) inputs into the following pins on your arduino:<\/p>\n<p>UP =&gt; D2<br \/>DOWN =&gt; D3<br \/>LEFT =&gt; D4<br \/>RIGHT =&gt; D5<br \/>BUTTON 1 =&gt; D6<br \/>BUTTON 2 =&gt; D7<br \/>BUTTON 3 =&gt; D8<br \/>BUTTON 4 =&gt; D9<br \/>BUTTON 5 =&gt; D10<br \/>BUTTON 6 =&gt; D11<br \/>START BUTTON =&gt; D12<\/p>\n<p>and of course if you don&#8217;t like this configuration, then you&#8217;ll have to edit this portion of the code:<\/p>\n<pre>const int PIN_OUT_UP = 2;\nconst int PIN_OUT_DOWN = 3;\nconst int PIN_OUT_LEFT = 4;\nconst int PIN_OUT_RIGHT = 5;\nconst int PIN_OUT_BTN_1 = 6;\nconst int PIN_OUT_BTN_2 = 7;\nconst int PIN_OUT_BTN_3 = 8;\nconst int PIN_OUT_BTN_4 = 9;\nconst int PIN_OUT_BTN_5 = 10;\nconst int PIN_OUT_BTN_6 = 11;\nconst int PIN_OUT_BTN_START = 12;<\/pre>\n<p>Upload the provided code into the arduino and test your device. The serial console is enabled by default so you can see each of the input and output lines in action. Use\u00a0230400 baud to connect to serial.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-619\" src=\"https:\/\/pcbjunkie.net\/wp-content\/uploads\/2018\/03\/arduino-genesis-console.png\" alt=\"\" width=\"930\" height=\"514\" \/><\/p>\n<p>That&#8217;s it!<\/p>\n<p>There is no warranty or support on this. Use it any way you&#8217;d like, but it also means that you&#8217;re responsible for bug fixes&#8230;. troubleshooting and customization. Enjoy!<\/p>\n<p>For more information, please watch my YouTube video on the subject.<\/p>\n<p>\u00a0<\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I created this for the super gun project that I just recently completed. It uses an arduino, one for each controller to decode the Sega Genesis controller protocol and interface the controls to an arcade game. You can see them buried behind all the wires in this photo. This is for an arduino nano developed &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/pcbjunkie.net\/index.php\/guides\/arduino-genesis-controller-interface\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Arduino Genesis Controller Interface&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":360,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-611","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/comments?post=611"}],"version-history":[{"count":6,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/611\/revisions"}],"predecessor-version":[{"id":33858,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/611\/revisions\/33858"}],"up":[{"embeddable":true,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/360"}],"wp:attachment":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/media?parent=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}