Introduction: Commodore 64 Revamp With Raspberry Pi, Arduino and Lego
This project lets you rediscover the 1980's gaming scene by resurrecting an old Commodore 64 home computer using new components and those ever-versatile Lego bricks! If you had one of these computers, this build will let you replay forgotten games and beat old high scores. If you're new to retro-computing, now's your chance to see why the Commodore 64 was so incredibly popular.
- A Raspberry Pi computer is used to replace the motherboard
- RetroPie provides the emulation platform for the Commodore (and other systems)
- A small Arduino Micro allows the Commodore 64 keyboard to be used as a fully operational USB keyboard
- Lego pieces are used to build the internal housing
- Keystone connectors provide the Commodore with USB, HDMI and network ports which are connected internally to the Pi
This project does not require programming or electronics skills. Makers who have used the Raspberry Pi or Arduino boards will find this build quite easy and it certainly helps if you have used Lego before - surely everyone has?!
This project will not physically alter the Commodore 64 case or keyboard, just in case you decide to use it in a different way in future. You may need to make repairs to an old one though.
These are explained in the steps which follow. They include the components needed for the main build and some optional parts needed if you want to include an on-off power switch.
Tools and software are required for the build and some items will be part of the completed assembly such as USB joysticks to play those classic games with!
Step 1: Get the Components Together
The components needed are listed in this section. If you don't have them all, there are links and suggestions available for getting hold of them with an approximate indication of price in US dollars (as at August 2019). It is worth reading this article in full to help decide on the Lego and exact cables you will use.
Once you have everything, you should be able to easily complete this build over a weekend.
- Ideally get a defunct machine but with a working keyboard. It would be a shame to dissemble a working machine or one that might need slight attention to repair! If you can't get a Commodore 64, then a Vic 20 or C16 should work instead with minor build changes mentioned in this guide
- The Commodore is probably the hardest part to get but they are available on eBay in the US and UK starting at around $50. Best to look at one that is being sold for parts and needs some TLC. You just need the case and keyboard so you may be able to purchase those parts separately
- The Raspberry Pi 2 and 3B will work well. The Pi 4 is a great new addition to the Pi family but check that you can get a Lego case for it. Also note that the cable requirements are different because it has micro-HDMI and USB-C ports
- A Pi 3B is available for around $35. Use your favourite search engine to find one or follow the link and change to your location: Raspberry Pi 3B+
Lego Raspberry Pi case
- This is the best choice for building the Pi into the internal Lego casing. There are so many cases for the Pi so it might be possible to get away with other options, fitting Lego pieces around it
- The Lego case from the Pi Hut was used for this build. It costs around $10 and comes in a choice of colours. Use this link to find one: Lego Raspberry Pi case
Micro SD card
- Your Pi will need a micro SD card to install RetroPie software onto
- RetroPie is an ideal choice if you will be using your Commodore 64 as a games machine
- Micro SD cards are widely available and are cheap, around $5. A 16GB card is an ideal choice for most users
Raspberry Pi power supply
- The official Raspberry Pi power supply is the safest choice
- You should be able to get the official power supply from the same place you get the Raspberry Pi from
- This small microprocessor translates the Commodore 64 matrix keyboard into a USB HID compliant keyboard which is plugged into the Pi
- The software needed to do the translation is available in this article and is uploaded to the Micro using the Arduino IDE. If you do a Vic 20 or C16 build, then this software will require minor changes to the matrix mapping table, explained later
- It is one of the smallest Arduino boards and costs around $20. Use your favourite search engine to find one or follow this link and change to your location: Arduino Micro
- This is used to connect the Arduino Micro to the 20 pin connector on the Commodore 64
- They are available from electronics shops and online, priced around $5. This link is for a half-size breadboard from Adafruit: Half-size breadboard
- These male to male and male to female jumper wires are used with the breadboard and to connect the Commodore 64 LED to GPIO pins on the Pi
- They are available from electronics shops and online, priced around $2 to $4 per pack. This link is for a 40 pack of 75mm male to male jumper wires from Adafruit: 40 pack of 75mm male to male. This link is for a 20 pack of 75mm female to male jumper wires from Adafruit: 20 pack of 75mm female to male
- These provide the USB, HDMI and Network ports on the Commodore 64 to plug into. They include:
- 2 x Keystone USB inserts
- 1 x Keystone HDMI insert
- 1 x Keystone RJ45 network insert
- Lego pieces generally fit well around Keystone inserts with some minor modification (mentioned in the build steps later). Cables from the Pi connect to the other end of the Keystone inserts
- They are available from electronics shops and online, the best place to start looking is probably eBay searching for "keystone usb", "keystone hdmi" and "keystone rj45". They are a standard size and each part costs between $5 and $10
- Cables between the Pi and Keystone inserts above are needed. These are:
- 2 x male to male USB cables
- 1 x male to female micro-USB extension cable
- 1 x male to male HDMI cable
- 1 x network lead. This cable will be cut in two for connection to the Keystone RJ45 network insert, so re-use an old one if possible. I found one with a broken clip on one end to re-use
- 1 x male USB to male micro-USB cable
- They are readily available from computer, TV and electronics shops and online, selling for around $5
- As they will all fit inside the Commodore, try to get short cables, around 20cm if possible. Avoid cables like my half-metre HDMI cable snaking around inside the case!
- A good assortment of Lego pieces are needed, particularly plates and bricks of varying lengths with a single stud width. For a Vic 20 or C16 build, you will need slightly different pieces to fit around their external ports compared to the Commodore 64
- They are available from toy shops, markets and on-line. I got most of the pieces needed from a Sunday market but pick-a-brick from the Lego shop website is a good online choice to get the exact pieces needed: Pick a Brick
Step 2: Decide If Having an On-off Power Switch
This build includes having an on-off power switch to safely turn the Pi off and back on. Having an on-off switch is nice to have but not essential because you can always turn off the Pi properly using RetroPie.
There are extra components and tools required. You can add the on-off switch in future if you prefer - we're using Lego after all!. Ignore the components below and steps 8 and 9 in this article if you are not going to have an on-off button.
- A momentary button is used to turn the Pi on and off. It is connected to GPIO pins on the Pi and software included in this article detects the button has been pressed and safely shuts down the Pi
- These are available from electronics shops and online. This link is for a 20 pack of 6mm buttons priced around $2.50 from Adafruit: 20 pack of 6mm buttons
- These female to female wire jumpers are used to connect the on-off switch to the GPIO pins on the Pi
- They are available from electronics shops and online, priced around $2 to $4 per pack. For a 20 pack of 75mm female to female jumper wires from Adafruit: 20 pack of 75mm female to female
Step 3: Get Equipment and Software Needed
The main equipment and software needed are listed below.
- PC (Windows or Mac) to download and install software
- RetroPie software, download from: RetroPie
- Arduino IDE software, download from: Arduino IDE
- FTP software to copy files from your PC to the Pi. If you need one, FileZilla is decent free option: FileZilla
- Monitor with HDMI cable to connect to the Commodore
- Network cable to connect to your home network and internet
- USB Joystick (ideally two)
- Spare USB keyboard for initial set-up and potentially for trouble shooting
- Screwdriver to dissemble and re-assemble the Commodore
- Trimming knife (Stanley knife) for trimming the Keystone inserts, cutting the network lead and the Lego brick on-off switch
- Medium-grain sandpaper to slightly modify the Keystone inserts so that Lego pieces can fit around them properly
- Soldering iron for the on-off switch
- Superglue adhesive for gluing the on-off switch to a Lego brick
Parts of this build involve using a sharp trimming knife. The pieces to trim and cut are quite small and will require some pressure to cut properly. Make sure the pieces are secure and won't slip as you work on them. If you are building the on-off switch, a soldering iron will be used, ensure you are confident in using one before proceeding.
No-one wants to get hurt while enjoying their hobby, so please get help if you need it.
Step 4: Prepare the Commodore 64 Case
Get the Commodore 64 case cleaned and ready for the next stages.
- Disconnect the keyboard and LED from the motherboard, then unscrew the motherboard from the case. Store the motherboard safely as it might be useful in future
- Depending on the condition of the unit, remove the keyboard and give the case a good clean with soapy water and leave to dry. Check if the case needs repairs, especially to the back case pins and front screw-in supports
- If needed, carefully clean the keyboard with a slightly damp kitchen towel. Avoid covering with water or using chemical cleaners. Reassemble the keyboard and case when done
Step 5: Prepare the Raspberry Pi
Set-up and install the Raspberry Pi with RetroPie software and complete the steps needed to copy files to it.
- Insert the Pi into the base of the Lego case. Do not close the Lego case at this stage because the GPIO pins will need to be connected later
- Install RetroPie onto the SD card and insert the SD card into the Pi. The links included here are for the RetroPie image: RetroPie and the Raspberry Pi website: Raspberry Pi Install SD Card
- Connect the monitor using the HDMI cable, attach the spare USB keyboard and a network cable into the Pi Ethernet port. Plug in the power supply to the Pi which should boot up and start RetroPie. There is no need to login, although the username and password are the default ones for the Pi: pi and raspberry
- When RetroPie starts up for the first time, it prompts for the input control mappings. Exit this for now by pressing F4 which takes you to the command prompt
- Enable SSH (secure shell) on the Pi so that you can access it from another computer and can copy files to it. Type sudo raspi-config and choose Interfacing Options > SSH > enable
- Find the IP (internet protocol) address for the Pi by typing hostname -I (minus and upper case i) at the command prompt and note it for next steps
- If you do not have FTP software, install it on your PC now. The FileZilla FTP client is recommended: FileZilla. Connect to the Pi using the FTP client software using the IP address of the Pi, port number 22 along with the username and password as shown
Step 6: Upload the Keyboard Mapping Software to the Arduino Micro
Set-up the Arduino Micro with the keyboard mapping software.
- Position the Arduino Micro onto the small breadboard and connect it to the PC using a USB to micro-USB cable
- Download and install the Arduino IDE onto your PC: Arduino IDE
- Install the keyboard and keypad libraries from the menu: Tools > Manage Libraries
- Create a new sketch (Arduino program) and copy the keyboard program code from the attachment on this page into the sketch
- On the IDE, use the menu Tools > Board and set the board to Arduino / Genuino Micro and assign the port it is connected to using the menu Tools > Port. Save, compile and upload the sketch
- If using a Vic 20 or C16, the Arduino sketch will need adjusting because they have a different keyboard matrix to the Commodore 64. Amend the arrays where the code defines the unshifted and shifted keys, using the link provided to assist in understanding the keyboard matrix for these computers: Keyboard Matrix Chart for Vic-20
uint8_t keys[ROWS][COLS] ... uint8_t shiftkeys[ROWS][COLS] ...
Step 7: Connect the Commodore, Arduino Micro and Raspberry Pi Together
Connect the Commodore 64 keyboard to the Arduino Micro using the jumper wires and breadboard.
- Using the pin mapping table shown, connect the Arduino Micro to the Commodore 64 20 pin header using the jumper wires and breadboard
- To tell the 'top' from the 'bottom' of the Commodore 64 20 pin header, the 'top' has missing pin connections for pins 2 and 4. The row pins (5 to 12) and column pins (13 to 20) are used for the Commodore keyboard matrix, while the restore key is separate on pin 3. The ground pin 1 needs to be connected for the restore key to work
- Unplug the Arduino from the PC and plug it into a USB port on the Pi
At the Pi command prompt, check all that Commodore 64 keyboard keys work properly. If you experience problems, then check this and the previous step carefully. There may be a poor connection or the keyboard might need a more extensive clean. The Commodore keyboard maps to a modern keyboard and the keys not found on the Commodore are available using the shift and control key as shown in the layouts
Step 8: Assemble the On-off Switch
The on-off switch is created from Lego pieces attached to a momentary button which is connected to two Raspberry Pi GPIO pins. Skip this step if you are not having an on-off button.
- Attach the two female-ends of the jumper wires to the pins of the momentary button. These will be connected to the Pi GPIO pins later. There are 4 pins on the momentary button which come in pairs. You need to connect the jumpers to one pin of each pair as shown. The connections should be secure. If not, use a soldering iron to solder into place
- The momentary button will be positioned onto a 2x2 modified Lego brick. Measure the distance between the pins of the button (usually around 6mm) and mark up the edge of the brick where it will need to be cut as shown
- Secure the Lego brick so that it won't slip and carefully cut into the brick. Lego is tough so you will need to apply some pressure using a knife. Other tools could be used including a small hacksaw or a Dremel. The end result should appear as shown
- Thread the pins of the momentary button into the Lego piece where the cut-outs have been made. If the fitting is a bit loose, then superglue the back of the button to the brick
- Build the switch housing section as shown. Note the flat Lego plate in front of the switch, which is used for a Lego button so that it can move smoothly along the plate
- Build the Lego button and superglue it to the top of the momentary button. The button should slide nicely inside the switch housing
Step 9: Set-up the On-off Switch Software on the Pi
Code is needed on the Pi to detect signals from the GPIO pins and initiate a safe shutdown of the Pi. Skip this step if you are not having an on-off button.
- Copy listen-for-shutdown.py and listen-for-shutdown.sh (rename from .shx to .sh) from the attachments on this page to the home folder on the Pi /home/pi
- The commands below make both files executable and move them to their destination folder. Then it updates the main start-up program to call the shutdown listener and starts it
### make both files executable sudo chmod +x listen-for-shutdown.py sudo chmod +x listen-for-shutdown.sh ### move them to their destination folder sudo mv listen-for-shutdown.py /usr/local/bin/ sudo mv listen-for-shutdown.sh /etc/init.d/ ### update the main start-up program to call the shutdown listener and start it now sudo update-rc.d listen-for-shutdown.sh defaults sudo /etc/init.d/listen-for-shutdown.sh start
- Test the button which should turn the Pi off via the normal shutdown process. When the Pi is off, press the button again to turn it on
Step 10: Create the Lego Foundations
Lego plates are fitted into the base of the Commodore 64 case for the other parts to connect to.
- The Lego foundations are created in two sections, one for the right hand side of the Commodore where the USB ports will be located, and the back section where the power, HDMI and network ports will be built
- Plate pieces are fitted around the internal grooves in the case. When both assemblies are turned over they fit with little movement, providing a sound base for the sections which follow
Step 11: Assemble the USB Ports
The two USB ports on the side of the Commodore 64 are created with Lego and Keystone pieces and cabled up to the Pi USB ports.
- The Keystone USB inserts need slight adjustment so that Lego pieces fit around them. Remove the clips using the trimming knife and sandpaper to remove the angular ridges so that they appear as shown. The original pieces are shown for reference
- Build Lego bricks around the Keystone USB inserts ensuring that the internal side of the USB port faces the front of the Commodore 64. Bricks are used to support the back of the insert which hold it in place when a USB cable is plugged in. The front of the USB insert rests on a small flat plate piece so that there is no gap on the front of the port
- Complete the build. Later, the male - male USB cables will connect the Keystone USB inserts and the Pi USB ports
Step 12: Assemble the Micro-USB Port
The micro-USB port for providing power to the Pi is built with Lego pieces and fitted to the back of the Commodore 64.
- Build Lego pieces around the female end of the micro-USB extension cable. This end may require trimming depending on the type of cable you have to ensure that it fits firmly inside its surrounding Lego pieces so that it can't be pulled out or pushed in when a cable is attached
- Complete the build. Later, the male end of the micro-USB will insert into the micro-USB power port on the Pi
Step 13: Assemble the HDMI Port
The HDMI port on the back of the Commodore 64 is created with Lego and Keystone pieces and cabled up to the Pi HDMI port.
- The Keystone HDMI insert needs adjustment so that Lego pieces fit around it and so that it extends out from the case of the Commodore 64, enabling easy connection with the HDMI cable. Trim the clip using a trimming knife and round off the bottom edges of the HDMI insert using sandpaper so that it appears as shown
- Build Lego around the Keystone HDMI insert making sure that the back of the clip is firmly held in place by a Lego piece. This prevents the HDMI insert from being pushed into the case when a HDMI cable is connected
Complete the build. Later, the HDMI cable will connect the Keystone HDMI insert and the Pi HDMI port
Step 14: Assemble the Network Port
The Ethernet port on the back of the Commodore 64 is created with Lego and Keystone pieces and cabled up to the Pi Ethernet port.
- The Keystone RJ45 insert needs adjustment so that Lego pieces fit around it and so that it extends out from the case of the Commodore 64, enabling easy connection with the network cable. Remove the clip and part of the top behind it using a trimming knife and round off the bottom edges of the RJ45 insert using sandpaper so that it appears as shown
- Using the trimming knife, cut one end off the network cable and thread it through a Lego piece with a hole in it. This can be quite a tight fit but helps support the back of the RJ45 insert for when a network cable is connected
- Cut the plastic shielding to expose the wires inside the cable. Connect the individual coloured wires according to the instructions provided with the Keystone insert, by pressing the wires into their respective metal placeholders. You do not need to expose the inner metal part of the wires beforehand as the metal placeholders will cut the plastic wire shielding and make the connection required. You might need a small blunt plastic knife to firmly push the wires into their placeholders
- Build Lego around the Keystone RJ45 insert
Complete the build. Later, the other end of the network cable will be connected to the Ethernet port on the Pi
Step 15: Combine All Parts and Test
The Pi GPIO connections are completed and all the pieces are assembled together.
- At this stage, you should have the keyboard and case sections ready to be connected to the Raspberry Pi
- Add the Lego case with the Raspberry Pi then connect the male-female jumper wires to the Raspberry Pi GPIO pins for the Commodore 64 LED as shown
- If you have made an on-off switch, connect the female end of the jumper wires to the Raspberry Pi GPIO pins as shown
- Close up the unused Commodore 64 ports on the back of the case with Lego bricks as shown. Then close the Raspberry Pi Lego case and ensure all Lego pieces are firmly in place and fit properly inside the Commodore 64
- Add Lego plates over the top of the fittings to strengthen them and hold the assembly in place even if the Commodore is held upside down
- Insert the cables from the keyboard and all the Keystone inserts. Then close down the Commodore 64 keyboard checking that it is seated properly and no cables are trapped
- Fasten the front screws but do not over-tighten them
Step 16: Set-up RetroPie
Finally, set-up the Commodore 64 emulator and games in RetroPie.
- The RetroPie website explains how to set-up emulators, install themes, scrape game box-art and where to put games files (roms). It is highly recommended that you look at this site to tap into all the features: RetroPie
- Boot up the Commodore 64 which starts RetroPie. It will prompt for input control mappings the first time it is used. Start with the keyboard and hold down a key to start the mapping process
- If the wrong key or joystick input is chosen when mapping, try using the up key on the keyboard to go back and remap it. If completely stuck, press F4 on the keyboard to exit RetroPie to the command prompt. Type emulationstation to start again
- To configure more than one input device (usually a joystick) in RetroPie, select Start > Configure Input and when prompted, hold down a key or button on the device. This starts the input control mappings dialog for the new device. Use this option to change the mapping for a device already configured
- To set-up the Commodore 64 emulator, called VICE, navigate in RetroPie as follows RetroPie setup > Manage packages > Manage optional packages. Select VICE emulator and choose Install from binary. It takes around 5 minutes to install
- Research where to legitimately get old games files (roms) and copy or ftp them to /home/pi/RetroPie/roms/c64
- Restart Emulation Station and your games will be visible. You should be good to go!
Step 17: Congratulations! Time to Play
You now have a Commodore 64 games platform which will hopefully serve you for many years to come! Don't forget to explore the other games platforms - you can for example, quite happily run Sinclair Spectrum and Atari games from your new Commodore 64!
In future I will probably look to get a PCB to connect the Commodore 20 pin header to the Arduino Micro replacing the small breadboard.
In the meantime, leave any comments and happy making!
Runner Up in the