[Daniel] is making a mini arcade cabinet with an SNES housed inside. He wanted to build an arcade controller for it and chose to construct something from scratch instead of destroying an original piece of hardware. We can almost feel you guys sighing with relief at that one. He sent us some nice photos of his build and pointed out that he’s using one of the Evilmadscientist AVR boards housing an ATtiny2313. The arcade buttons are readily available at sparkfun. The source code for this project is available after the break.
/** * Emulate a 16-bit input shift register with integrated pullup resistors. * In other words, a SNES controller. * * Daniel Holth */ #include #include #include ISR(SIG_PIN_CHANGE) { /* Pin change interrupt for latch */ USIDR = PINA | (PIND &amp; 0b01111100) | (PINB &lt;&lt; 7); USISR = (1 &lt;&lt; USIOIF); // clear overflow bit, set counter to 0 USICR |= (1 &lt;&lt; USIOIE); // enable overflow interrupt } ISR(SIG_USI_OVERFLOW) { /* USI finished shifting out 8 bits... */ USIDR = (PINB &lt;&lt; 3) | 0x0f; USISR |= (1 &lt;&lt; USIOIF); // clear overflow bit USICR &amp;= (0xff ^ (1 &lt;&lt; USIOIE)); // disable overflow interrupt // TODO: output should be low after all 16 bits have been read out, // according to <a href="http://www.raphnet.net/electronique/arcade_control/arcade_control_en.php" target="_blank">http://www.raphnet.net/electronique/arcade_control/arcade_control_en.php</a> } int main() { USIDR = 0xff; USICR = (1 &lt;&lt; USIWM0) | (1 &lt;&lt; USICS1); // 3-wire mode; external, positive edge. // USICR = (1&lt;&lt;USIWM0)|(1&lt;&lt;USICS0)|(1&lt;&lt;USICS1); // negative edge DDRA = 0; DDRD = 0; DDRB = 1 &lt;&lt; 6; // MISO // Enable pullups PORTA = 0x3; PORTB = 0b11111; PORTD = 0xfc; // USIDR is shifted out MSB first. // pin change interrupt for latch pin PCMSK = (1 &lt;&lt; 5); GIMSK |= (1 &lt;&lt; PCIE); sei(); while (1) { sleep_mode(); } }
Why use a microcontroller when you can get by with only two 8-bit shift-registers (4021Bs)? I’m sure the 4021B is much cheaped than any microcontroller.
maybe im not awake enough yet but couldnt this be done with a couple 74hc597’s chained together?
as Frode stated, a SNES controller is just two 4021 shift register chained together. The SNES provides power, clock and latch. I can’t see something easier.
For the “cost” of a ATtiny2313, it should include an autofire mode or something like that.
You can get micros pretty cheap. At least with a micro you can add functionality pretty easily later, like rapid fire and etc.
you can add variable rapid fire with a 555, but your right it is much easier to expand, which could be handy if you want a rack of old game machines sharing the one controller
Looks familiar, aside from the mangling of the angles in the source code. Yes, a pair of shift registers could have done it, but if an MCU is what you have on hand… besides, it’s a learning experience.
love the controller he built but the micro controller is overkill unless he plans to wire it up to more than one console. If it is just for an SNES then he should have gotten one of those horrid 3rd party controllers for like a dollar at thrift store and just used its PCB. or just used the shift registers like stated above. this is OVERKILL. =D
I keep seeing people mention that the microcontroller will allow him to add some functionality later on. What better functionality for your favorite arcade fighter then MACROS. ‘b+a+right trigger+up’ entered in one button press for a sweet super punch. And recording them and playing them back would be really easy with that ATtiny. That and a small menu would allow you to select a set of them really easy.
I have to critique his choice in a stick. The zippyy stick is a skoppy knockoff of the Seimitsu LS32 joystick. If he removed that bootleg and put in a nice, authentic joystick, he’d have a lot more fun with the joystick, I guarantee it.
Eh. Not sure why people are complaining that much.
The 4021Bs cost about $0.60 each and the ATtiny2313 is about $2.60 each according to Digikey. Its roughly 2x more expensive but thats only ~$1.30 which isn’t much.
If Daniel was going to put this design into mass production and doesn’t intend to add any other features to it at all then sure, its a waste of money but otherwise, not a big deal IMO.
@GotNoTime Those who talk the most about it are usually the ones who do the least :-)
This is my project. I’m quite aware I wasted a dollar, and a couple of hours of programming time, by using the micro. I /also/ destroyed a knockoff SNES controller to get the plug.
On the other hand I had a micro, the EMS protoboard is a much nicer place to solder the wires than a gamepad circuit board with holes drilled in it, and I didn’t have to fiddle with soldering 12 pullup resistors because they are built into the micro. I learned how to use the Universal Serial Interface and I left the USART free in case I ever want to add serial communication.
Great tip about the higher quality Seimitsu joystick. It’s barely more expensive than the one I used. By no means is this an “easier” controller than the gamepad, but it is a really fun way to play. If I build another one I’ll try using higher quality parts.
great! hope we see the finished cabinet here someday. i build mine using the “dirty controller hack”, means ripping an standard usb controller apart and soldering the wires of the new switches directly to the board, worked great for me. see here: controller: http://bit.ly/fwnJrI and the whole project: http://bit.ly/bIrnZp
ain’t it easier to solder the buttons straight to a snes controller, it did work for my as it worked too when i did it with a PS2 controller and an USB pc controller, also i’m going to do it with a X-box 360 broken controller i have liyng arround.
This is WAY too much work. Sure its cheaper than buying an i-Pac. But now this device will only run SNES games. For all the effort you should just build a full MAME enclosure with a PC at the core. Then you could run SNES, MAME, Sega, NES, and a host of other games. For almost the same level of work and expense.
What’s with the #include statements? This code most definitely will not compile.
Your doing it all wrong…. You really should have used some Tube amps and some Nixie tubes! Some peoples kids these days!
Awesome HACK (By all definitions btw)
Keep up the good work!
I think you will need a thicker or harder table to withstand shocks when playing…
where is the audrino and leds?
The ATTiny2313 only costs 1.85 euro where I live. +0.40E for the socket. So 2.25 euro for the whole deal.
Shift registers, 0.60E, x2, add sockets: (0.60E + 0.40E) x2 = 2.00E.
So for 0.25E you can add autofire mode, and a smaller package.
But look up the prices for those buttons and joystick, and you’ll notice that the electronics used are not really part of the costs.
Very cool. I tried to make a controller by modifying a wireless keyboard. It worked somewhat for simple games, but after a while I just bought an encoder. Wireless keyboard control was cool, but a bit limited.
Here’s the link to the original project if anyone wants to see: http://jcopro.net/2010/11/22/wireless-mame-experiment-part-1-introduction/
Nice doing. I have used some snes controllers with the directpadpro type connection for my emulation needs, however snes controllers are increasingly harder to find and I would like to use the shift registers as pointed, does anyone has diagram or schematic? Thanks.