Breadboard RetroPie
This Instructables show how to build a Breadboard RetroPie, no soldering, no 3D printer, no Laser cutter required.
Building a game machine is a very good project to initial child studying electronics. However, most RetroPie projects built by adult, the main reason is building it require too many advance skills at the same time, soldering, 3D printing, or Laser cutting, metal case patching...
This project aims to make it simple, all things built on the breadboard, the first tools you should know while studying electronics.
The most beauty thing using breadboard is most things can be reused. When you want to build the next project you can unplug and reuse the components and also reuse the breadboard itself!
Preparation
Raspberry Pi Zero
I know it is cheap but very hard to buy one, if you want the built-in WiFi feature, Zero W is easier to get and also it can enable net play for your game machine
Micro SD card
Please check RPi compatible SD card list here: http://elinux.org/RPi_SD_cards
LCD Module
2.8 inch ili9341 LCD Module
Base Plate
A 165 mm x 112 mm plastic plate help to combine all component together
Breadboard
This project require connect Raspberry Pi Zero, 2.8 inch LCD, 12 controller buttons, power and audio components all together. So it require various size breadboard connected together:
- 1 x 830 hole breadboard
- 3 x 170 hole Tiny breadboards
Breadboard Wire
Breadboard's best friend
Fishing Line
0.3mm Nylon fishing line, it helps to fix pin header to Pi Zero without soldering
Pin Header
2x40 18mm pin header
Actually it only require 2x20 pins, but the pins is very easy broken while patching, so buy more for backup purpose
Button
Any breadboard friendly button is OK, I an using:
- 10 x 12 mm buttons with button caps
- 2 x 6 mm buttons
Battery Holder
2 x 2 AA Battery Holder
Power Switch
Any breadboard friendly switch is OK
DC-DC 5 V Regulator Module
Battery Holder, power switch and DC regulator combined to provide 5 V power supply to Pi Zero. I recommend using rechargeable battery for environment reason, 4 rechargeable AA battery provide 4.8 V power, it is a little bit lower than 5 V but Pi Zero can tolerate a little bit power shortage. If you always use rechargeable battery, DC regulator can be skipped.
Screw Terminal Block
3 x 2 pins screw terminal block, 2 for battery holder and 1 for speaker
Audio Component (Optional)
- 33nf capacitor
- 10uf capacitor
- 47k Ohm resistor
- NPN transistor (e.g. 2N2222)
- A tiny speaker (can be found in old gadgets)
Others
A computer, a card reader and micro USB cable for flashing the RetroPie image and initial settings
Design Layout
Breadboard split into 2 breadboard panels. Lower panel base on my previous project (Pi Zero on the Breadboard); upper panel combined with 3 tiny breadboard.
At the lower panel:
- Raspberry Pi Zero placed at the middle
- Left side is direction buttons
- Right side is 6 action buttons
- Above Pi Zero is select and start buttons
At the upper panel:
- LCD placed at the middle
- Besides LCD is power button and audio components
- Speaker placed above the LCD
- Left and right side are 2xAA battery holder
Prepare Pi Zero on the Breadboard
Please prepare Pi Zero on the Breadboard according to my previous instructables:
Install Game Buttons
Some buttons may need some adjustment to fit on the breadboard firmly.
The buttons layout just depends on your preference, the only thing need to follow is one button terminal connect to GND and another terminal connect to a Pi Zero GPIO.
Connect All Buttons 1 Terminal to GND
Connect Buttons Another Terminal to a Pi Zero GPIO
Here is the buttons connection summary:
GND -> Up -> GPIO 22 GND -> Down -> GPIO 17 GND -> Left -> GPIO 27 GND -> Right -> GPIO 4 GND -> A -> GPIO 26 GND -> B -> GPIO 19 GND -> L -> GPIO 13 GND -> X -> GPIO 5 GND -> Y -> GPIO 21 GND -> R -> GPIO 20
Install Select and Start Button
Buttons connection summary:
GND -> select -> GPIO 16 GND -> start -> GPIO 6
Decorate Button Caps
Measure and Cut Base Plate
Make Sharp Corner Round
Stick Breadboard Altogether
Stick the Battery Holder
Install Battery Holder Wire to Terminal Block
Connect Power Wire
Install Power Switch
Here is the battery power connection summary:
left battery holder -ve -> right battery holder +ve left battery holder +ve -> power switch -> 5 V regulator (optional: only for non-rechargeable battery) -> breadboard 5 V right battery holder -ve -> breadboard GND
Connect LCD Wire
Here is the LCD connection summary:
LCD Vcc -> breadboard 5 V LCD GND -> breadboard GND LCD CS -> GPIO 8 LCD Reset -> GPIO 25 LCD D/C -> GPIO 24 LCD MOSI -> GPIO 10 LCD CLK -> GPIO 11 LCD LED -> GPIO 15
Install Audio Component
Here is the audio component connection summary:
GPIO 18 -> 33nf capacitor -> breadboard GND GPIO 18 -> 10uf capicitor -> NPN transistor base pin NPN transistor emmitter pin -> breadboard GND NPN transistor collector -> speaker -> breadboard 5 V
Install the LCD Modules
Download RetroPie Image
Please download RetroPie image here:
https://retropie.org.uk/download/
Select "Raspberry Pi 0/1" option to download the image for Raspberry Pi Zero.
Download Source
2 further source code required for the Breadboard RetroPie:
mk_arcade_joystick_rpi: https://github.com/recalbox/mk_arcade_joystick_rp...
rpi-fbcp: https://github.com/tasanakorn/rpi-fbcp
Simple click "Clone or download" button and then "Download ZIP" from both source web page.
Prepare ROM Files
For the non license free game, I think you should only use the ROM that you have the original game.
Or you may find some license free games here:
Flash the RetroPie Image
Copy Files
Copy "mk_arcade_joystick_rpi-master.zip", "rpi-fbcp-master.zip" and your game ROM to the RetroPie micro SD just created.
Configure Micro SD
We need further config after RetroPie boot, before that, we need to enable DWC2 USB controller to make network connection between computer and Pi Zero.
Edit the config.txt in micro SD, append the follow line at the tail:
dtoverlay=dwc2
Edit the codlin.txt in micro SD, insert "modules-load=dwc2,g_ether" after "rootwait" keyword. The result should be something like that:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet loglevel=3 consoleblank=0 plymouth.enable=0 quiet init=/usr/lib/raspi-config/init_resize.sh
Create a blank file called "ssh" in the micro SD to enable openssh server, e.g. in my Mac:
touch /Volumes/boot/ssh
USB Connect
Insert the micro SD to Pi Zero and connect the Pi Zero 2nd USB socket (labelled "USB") to the computer.
Wait around a minute, you should find a new network adaptor in your computer. Type the follow command connect to the Pi Zero:
ssh pi@retropie.local
P.S. default password is "raspberry", you should change it ASAP by "passwd" command
Configure LCD
Append to "/etc/modules"
spi-bcm2835 fbtft_device
create the "/etc/modprobe.d/fbtft.conf"
options fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:15 speed=48000000 rotate=90 bgr=1
Enable Fbcp
Extract source files:
unzip /boot/rpi-fbcp-master.zip
Compile and install:
cd rpi-fbcp-master/ mkdir build cd build cmake .. make sudo install fbcp /usr/local/bin/fbcp cd ../..
Insert the follow line before "exit 0" in "/etc/rc.local"
/usr/local/bin/fbcp &
Append the follow line in "/boot/config.txt" at the tail:
hdmi_force_hotplug=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt=320 240 60 1 0 0 0 disable_overscan=1 dtparam=spi=on
Configure Joystick
Extract source files:
unzip /boot/mk_arcade_joystick_rpi-master.zip
Edit buttons definition:
cd mk_arcade_joystick_rpi-master/ vi mk_arcade_joystick_rpi.c
Find the "static const int mk_arcade_gpio_maps[]" row and update to your button definition, e.g. my definition:
static const int mk_arcade_gpio_maps[] = {22, 17, 27, 4, 6, 16, 26, 19, 20, 5, 21, 13};
Compile and install module:
sudo mkdir /usr/src/mk_arcade_joystick_rpi-0.1.5/ sudo cp -a * /usr/src/mk_arcade_joystick_rpi-0.1.5/ export MKVERSION=0.1.5 sudo -E dkms build -m mk_arcade_joystick_rpi -v 0.1.5 sudo -E dkms install -m mk_arcade_joystick_rpi -v 0.1.5
Test the buttons:
sudo modprobe mk_arcade_joystick_rpi map=1 jstest /dev/input/js0
Append to "/etc/modules"
mk_arcade_joystick_rpi
create the "/etc/modprobe.d/joystick.conf":
options mk_arcade_joystick_rpi map=1
Design Your Own Button Layout
Updated: 2017/05/18
Breadboard is very easy to plug and unplug the components, please feel few to try and design your own button layout.
If you have changed the GPIO connection, you may run the follow script to recompile the modules:
cd mk_arcade_joystick_rpi-master/ export MKVERSION=0.1.5 sudo -E dkms uninstall -m mk_arcade_joystick_rpi -v 0.1.5 vi mk_arcade_joystick_rpi.c sudo rm -rf /usr/src/mk_arcade_joystick_rpi-0.1.5/ sudo mkdir /usr/src/mk_arcade_joystick_rpi-0.1.5/ sudo cp -a * /usr/src/mk_arcade_joystick_rpi-0.1.5/ sudo -E dkms build -m mk_arcade_joystick_rpi -v 0.1.5 sudo -E dkms install -m mk_arcade_joystick_rpi -v 0.1.5
Enable GPIO 18 Mono Audio
Append the follow line in "/boot/config.txt" at the tail:
dtoverlay=pwm,pin=18,func=2
Ref.:
Copy ROM Files
Copy ROM files from "/boot" folder to "~/RetroPie/roms/$CONSOLE" folder
Boot RetroPie
- Turn off the RetroPie:
sudo halt
- Unplug the USB cable
- Insert fully charged AA battery
- Turn on the power switch
- Follow screen instruction to config the game button
- Select the console and game
- Enjoy!
Happy Studying!
Breadboard RetroPie is a good starting point of learning Raspberry Pi. It's time to start a Raspberry Pi project with your child!