Creating a mini NES with a Raspberry Pi

Creating a mini NES with a Raspberry Pi
Mini NES RetroPie
Mini NES RetroPie

It all started with the Nintendo Classic craze. I had a friend that was rambling about one the other day. I mentioned that I could totally make him one but better because it would emulate more than just Nintendo. Enter RetroPie. I was looking at putting the bill of materials together and thinking of cases for the mini NES, then I realized why not just print one! So BAM and BAM.

 

https://www.thingiverse.com/thing:1887826 
then this https://www.thingiverse.com/thing:2011955 

Then this for giggles
https://www.thingiverse.com/thing:1710104

 

Here’s what we are doing

  1. Flashing RetroPie to an SD card for a Raspberry Pi
  2. Soldering header pins to the RUN pin holes on the RPi
  3. Soldering wires to some push buttons
  4. Soldering some wires to an LED
  5. 3D Printing a mini NES case for the RPi
  6. 3D Printing a bracket for the NES case
  7. Glueing push buttons, LED and bracket into the printed case
  8. Wiring the LED and buttons to the RPi
  9. Testing it all

 

Here’s what you need

  1. Raspberry Pi (save yourself a headache, get a RPi 3!)
  2. RPi power supply MINIMUM of 2.5A!
  3. SD card 8gb+ class 10
  4. HDMI cable
  5. USB keyboard
  6. Network cable (even though the RPi 3 has wifi you will at least need to do the initial wifi setup with a LAN connection)
  7. A 3D Printer to print the case and the bracket
  8. (2) push buttons
  9. (2) male header pins
  10. Super glue and hot glue
  11. (1) red LED
  12. (1) 100 ohm resistor
  13. (6) pieces of jumper wire with connections (you can cut some in half if long enough)

 

Whats Up

I will assume you have a network connection (non wifi) a USB keyboard a TV or Monitor or tv with an HDMI connection and that you have active internet. You will need to know how to solder, and be somewhat comfortable with a terminal and hopefully the Linux environment. I also assume you have and know how to use a 3D printer. I will also assume that you know and are comfortable with Raspberry Pies. Lots of ASSumptions.

This post is not designed as a how to install RetroPie but more of a how to get RetroPie installed and create the scripts for shutdown the Pi and lighting the LED, then you can follow the first install guide by RetroPie to get you going with the actual RetroPie software.

If you want to use WiFi

With a keyboard and TV/Monitor connected follow this https://github.com/RetroPie/RetroPie-Setup/wiki/Wifi, otherwise…

Let’s Get Started

3D print the case and button/LED bracket. Solder up some of the jumper wires to the push buttons and then solder the resistor to the LED and some wires. Glue this all together in the bottom of the case). Check the Thingiverse page for more information on all this as well.

Go download the newest version of RetroPie. Once that is downloaded you need to flash the image to an SD card, preferably 8gb or higher, class 10. There are a few ways to get the image on the SD card. Apple-Pi Baker, Etcher, or use the  dd command or Win32DiskImager.

RetroPie first installation

https://www.raspberrypi.org/documentation/installation/installing-images/windows.md
https://www.raspberrypi.org/documentation/installation/installing-images/mac.md
https://etcher.io/
https://www.tweaking4all.com/downloads/#Raspberrypi

Once you got the image on the SD slap it in the RPi and boot. You will need to have the unit connected to a TV/Monitor and you will need a controller. A keyboard connected to the Pi is required (at least momentarily). Once the unit boots it  will want you to map the keyboard keys to the buttons. Just hit F4  or Shift+F4 to get a terminal. From there we need to set up some defaults and turn on auto login on the Pi so the script runs on boot.

sudo raspi-config

 

How do I change the default password

  1. Select option “1. Change User Password”
  2. Follow the prompts to set the new password. The default password is raspberry.

How do user auto login

  1. Select option “3. Boot Options”
  2. Select option “B1. Desktop / CLI”
  3. Select option “B2. Desktop Auto login”
  4. Don’t quit or reboot yet, go back to the main menu

How do I extend the available space when upgrading to a larger SD card

  1. Select option “7. Advanced Options”
  2. Select option “A1. Expand Filesystem”
  3. Reboot your Raspberry Pi (or do the optional SSH)

How do I enable SSH on RetroPie?

  1. Select option “5. Interfacing Options”
  2. Select option “P2. SSH”
  3. Select YES
  4. Reboot your Raspberry Pi

Once it reboots you can then SSH into the Pi or continue to use the keyboard attached.

See RetroPie first installation for more info on installing RetroPie. See https://retropie.org.uk/docs/FAQ/ for more answers to questions.

Check out the directions on https://www.thingiverse.com/thing:2011955, they are pretty decent and should get you most of the way through as well. Most if not all of this information is compiled from there. First things first, from the terminal:

 

 

Install wiringPi

Taken from http://wiringpi.com/download-and-install/

Let’s check to make sure you don’t have wiringPi already (if you used the RetroPie image you do NOT). If it spits back a version number, you do. If you do then (we need to purge it, to update to the newest):

You will need GIT installed to install wiringPi. If you are using the RetroPie image you already have it. To install GIT:

sudo apt-get install git-core

Then pull a copy of wiringPi:

git clone git://git.drogon.net/wiringPi

Check to see if you have the most recent version of wiringPi (which you should):

Now build:

sudo ./build

You should have wiringPi, to check:

gpio -v

Reboot.

 

Making the LED work, and run on boot

Check here for more information. From a terminal:

Paste this into the new file:

ctrl+o  to save ctrl+x  to quit, then let’s create another file to turn off the LED:

sudo nano Scripts/LEDoff.py

Paste this into the new file:

Of course change the pin (18 in this example) to whatever GPIO you are using. You can test the scripts by using:

sudo python ~/Scripts/LEDon.py  or sudo python ~/Scripts/LEDoff.py . Now let’s make it turn on when the Pi boots.

Making the LED illuminate on boot

We need to edit rc.local:

sudo nano /etc/rc.local

Add this to the file before the end of the loop:

sudo python /home/pi/Scripts/LEDon.py &

The “&” is important, don’t forget to have that there. For example:

ctrl+o to save, ctrl+x to quit. The LED should automatically turn off when the Pi shuts down (unknown what will happen if the Pi just freezes, I imagine it would stay lit).

 

Making the RUN (reset) pins work

  1. Solder some male header pins to the empty spot marked RUN on the RPi board
  2. Simply connect the reset button to the RUN pins and done.
  3. Anytime you press the reset the Pi should, well, reset.

 

Making the shutdown button work

Check out  https://www.element14.com/community/docs/DOC-78055/l/adding-a-shutdown-button-to-the-raspberry-pi-b for more information on all this.

The python script

We need to create a new directory and a shutdown script:

Paste this in the new file you just created:

Edit the above and change the GPIO (18 in the example) to whatever pin you are using. Then save (ctrl+o) and exit (ctrl+x). You can test the new script by running (it should shutdown, if you already did the reset/RUN pin then you can use that to reboot):

sudo python Scripts/shutdown.py

Making it run on start

We need to edit rc.local:

sudo nano /etc/rc.local

Add this to the file before the end of the loop:

sudo python /home/pi/Scripts/shutdown.py &

The “&” is important, don’t forget to have that there. For example:

 

Then you are good to go, reboot for the changes to take effect. The script you created should start automatically upon reboot.

The LED should light on when RetroPie starts, the shutdown button should power down the RPi and kill the LED and the reset button should reboot the Pi from its shutdown state. Let me know if I missed anything.

Leave a Reply

%d bloggers like this: