Category Archives: Electronics

NES controller for PC via Arduino

I’ll be updating the 2.x Laser build soon, but I got a little sidetracked while working on it.  The laser is going to have a manual trigger for calibration purposes.  I decided to use a NES zapper because, well, I can.  So in testing the zapper as a switch I added some LEDs and made this (sorry for potato quality pictures):

DSC04524

DSC04526

DSC04528

Then I got really sidetracked with how the NES controller works and decided to mess with it.  Using the same timing that the NES uses to interface with the controller (found here), I wrote an Arduino sketch to get the input.  The shift register will respond to a wide range of timing on the pulses, but I decided to use the exact timing that the NES uses so that I can try to use other methods of input through the Arduino to the NES (that will be a future project, voice control? kinect?).

I also found this post where he uses a library someone created, but that seems kind of unnecessary.  Besides, the sketch I wrote was made to work with a program written in processing for converting the serial output to keyboard commands.

NEScontroller_pinout

This is a better picture of the pinout.  What was labeled “Pulse” in the other link is “Clock” here, and “Latch” is “Strobe”.

Now here’s how to make it work as a controller for an emulator or anything else. this instructable explains how to use an N64 controller via Arduino and a program written in processing.  In the instructable, he claims that if you are using a newer version of processing (newer than 1.0), that you need to import a few extra packages.  I found that with processing 2.2.1 in addition to the packages mentioned, you also need to import the KeyEvent package.  Here’s a link to the same program with all the necessary packages imported.

https://www.dropbox.com/sh/k9upeif77zrsdll/AACvHLZ6ANmZ9b3LDDP-0H5Ka?dl=0

It is possible to just stick some wires in the NES controller output socket and go straight to the arduino.  I found this method to result in somewhat loose connections so just to be safe I used the connector from the NES itself and wired from there (the breadboard looks more cluttered than it should because I was moving stuff around).

arduinoNES

The processing program was modified from one that was originally made to interface with a gamecube controller.  Instead of modifying it again to make it work with an NES controller (we’re going backwards apparently), I just left it as it is and made the NES controller output from the Arduino match the format of the N64 controller output.  My arduino sketch is here:

https://dl.dropboxusercontent.com/u/27794628/NES_Arduino.ino

Run this arduino sketch, then run the processing sketch and make sure the serial port is the same: “You might need to change the line String portName = Serial.list()[1]; to match the your Arduino, it should be either Serial.list()[0]; Serial.list()[1]; or Serial.list()[2];”   This should result in a working NES controller for your computer.

Of course after I do all this I find an easier method: https://gist.github.com/j-mcc1993/8202522

But, my effort was not entirely wasted.  The keyboard library only works on the Arduino Leonardo, Micro, or Due apparently so it wouldn’t have worked on my Uno anyways.  Other methods that I have seen involved updating firmware and more complicated things.  The method I have here is pretty straightforward and easy.

And now I made an Instructable for it so people can actually find it if they are looking: http://www.instructables.com/id/Using-an-NES-controller-for-emulators-with-Arduino/

Advertisements

2.x Laser

This is mainly intended for hack.rva members that are interested in finishing building the laser.  I made a page with a bunch of sub-pages to organize what is left of the build.  If anyone has input you can email me or just comment on this post (I don’t think you can comment on the actual page).

https://computationalphysmatronics.wordpress.com/projects/2-x-laser-build/

If any random internet person that stumbles across this has any constructive feedback or input on the project, especially if you have done something similar, feel free to comment here on this post as well.

Binary Counter

So when I first started messing with electronics stuff I decided to try to understand things starting with the simplest components and working up from there.  I found a binary counter IC and wired together something to convert its binary counting to sequential counting by using transistors as digital logic gates.  I cheated a little bit and used some packaged IC NOR gates but still this is on a pretty fundamental level of digital logic.

DSC05143

The battery connected to the voltage regulator on the left goes to a 555 timer that is just pulsing a signal to the binary counter.  The battery also powers the red LEDs and if I remember correctly the other battery is to power the yellow LEDs because the voltage drop through the 555 and a red LED didn’t leave me with enough for another LED at the same time with the way it was wired. The outputs directly from the counter are displayed on the yellow LEDs and the same outputs pass through all the digital logic crap and light up the red LEDs sequentially.

Using these larger discrete components makes you realize how much goes into these small chips we have even for very simple functionality.  Just the 555 timer itself could be made with the same transistors and resistors I used for the logic parts here.  Take a look at this kit where you can do just that http://www.evilmadscientist.com/2013/555-kit/555 kit And here’s a video of the counter in action.  There’s an episode of Futurama playing in the background providing the somewhat epic commentary.