Commodore 64 Revamp With Raspberry Pi, Arduino and Lego




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.

Commodore 64

  • 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

Raspberry Pi

  • 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

Arduino Micro

  • 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

Half-size breadboard

  • 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

Jumper wires

  • 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

Keystone inserts

  • 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.

Momentary 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

Jumper wires

  • 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 and (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
    sudo chmod +x
    ### move them to their destination folder
    sudo mv /usr/local/bin/
    sudo mv /etc/init.d/
    ### update the main start-up program to call the shutdown listener and start it now
    sudo update-rc.d defaults
    sudo /etc/init.d/ 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!

      Games Contest

      Runner Up in the
      Games Contest

      Be the First to Share


        • Battery Powered Contest

          Battery Powered Contest
        • Plywood Challenge

          Plywood Challenge
        • Plastic Contest

          Plastic Contest

        24 Discussions


        Question 11 months ago

        I am making this as a Christmas present and have run into a problem: Shutdown switch
        all of the lines of code work but upon entering the last line of the set up, the response is : unable to execute /etc/init.d/ start : no such file or directory. using filezilla is in /etc/init.d/ with permissions -rwxr -xr -x
        any suggestions?


        Answer 11 months ago

        Hi, the owner of these files is root on my Pi, if yours is different, use: sudo chown root /etc/init.d/ to change it. Another thing to try is logging in as root and try running it. Might have other suggestions but worth checking these first


        Reply 11 months ago

        Hello again

        I tried the chown root….sh, but got “chown: cannot access ‘ /etc/init.d/…sh’ : no
        such file or directory as a reply

        Using filevilla,
        I tracked down where could be found and it was in the
        root directory in the etc/init.d sub-directory where input instructions told it
        to reside.

        I ran PWD on the
        raspberry pi command line and got

        Ran cd .. until I
        was in the root directory

        Then ran cd until
        I was in the /etc/init.d directory where I typed sudo
        start and got “ no such command found”.

        Well on the bright side, something works. If I shut down the
        raspberry pi, and before I turn off the power, I press my on/off switch, then
        the pi starts back up again. When I try the on/off switch while the Pi is on
        the green light twinkles but nothing else happens. I must use the shutdown –h now command to
        turn it off.

        Any suggestions




        Reply 11 months ago

        Hi Larry
        A couple of things to try, create a script using nano which just does a simple echo "hello", set execute permissions and run in the/etc/init.d directory. That should work and if so, copy paste the contents to that file, rename and run it. Hopefully that will do it. I use putty and copy paste code like this from Windows. Text files on Windows include carriage return and line feed characters on the end of lines, whereas Linux just uses line feeds and I think that is the problem. Copy paste from Windows to Linux works though.


        1 year ago

        I love those spherical keycaps! Are they double-shot?


        Question 1 year ago on Introduction

        I've wired up an Arduino Micro, exactly, as your pinout description. I've taken your, keys, rowPins and colPins and put them into a simple program using Keypad to output the key/codes found to the serial port. EVERYTHING is working fine... EXCEPT... if I hit any key in row 7 (e.g. 2, 4 6, 8, etc) the micro resets. ONLY this row! Also there is cases where any of the rows that have two defined values at the end of the row (e.g. {'1','3','5','7','9','+',KEY_POUND, KEY_DELETE},) both of the last two keys respond with TWO codes.. If I hit the pound key I get back both KEY_POUND and KEY_DELETE. If I hit the delete key I get back both the KEY_POUND and KEY_DELETE codes.
        This second condition, I'll figure out, but the reset issue has me baffled.
        Any thoughts or ideas to look at?

        Here's the code if you feel adventurous.



        /* @file MultiKey.ino
        || @version 1.0
        || @author Mark Stanley
        || @contact
        || @description
        || | The latest version, 3.0, of the keypad library supports up to 10
        || | active keys all being pressed at the same time. This sketch is an
        || | example of how you can get multiple key presses from a keypad or
        || | keyboard.
        || #
        #include <Keypad.h>
        #define KEY_TAB 0x09
        #define KEY_RETURN 0x0d
        #define KEY_ESC 0x1b
        #define KEY_QUOTE 0x22
        #define KEY_HASH 0x23
        #define KEY_APOSTROPHE 0x27
        #define KEY_AT_SIGN 0x40
        #define KEY_LEFT_SQUARE 0x5b
        #define KEY_BACKSLASH 0x5C
        #define KEY_RIGHT_SQUARE 0x5d
        #define KEY_PIPE 0x7C
        #define KEY_TILDE 0x7E
        #define KEY_DELETE 0x7f
        #define KEY_POUND 0x9c
        #define KEY_NULL 0xFF
        #define KEY_LEFT_CTRL 0x80
        #define KEY_LEFT_SHIFT 0x81
        #define KEY_LEFT_ALT 0x82
        #define KEY_LEFT_GUI 0x83
        #define KEY_RIGHT_CTRL 0x84
        #define KEY_RIGHT_SHIFT 0x85
        #define KEY_RIGHT_ALT 0x86
        #define KEY_RIGHT_GUI 0x87
        #define KEY_UP_ARROW 0xDA
        #define KEY_DOWN_ARROW 0xD9
        #define KEY_LEFT_ARROW 0xD8
        #define KEY_RIGHT_ARROW 0xD7
        #define KEY_BACKSPACE 0xB2
        #define KEY_TAB 0xB3
        #define KEY_RETURN 0xB0
        #define KEY_ESC 0xB1
        #define KEY_INSERT 0xD1
        #define KEY_DELETE 0xD4
        #define KEY_PAGE_UP 0xD3
        #define KEY_PAGE_DOWN 0xD6
        #define KEY_HOME 0xD2
        #define KEY_END 0xD5
        #define KEY_CAPS_LOCK 0xC1
        #define KEY_F1 0xC2
        #define KEY_F2 0xC3
        #define KEY_F3 0xC4
        #define KEY_F4 0xC5
        #define KEY_F5 0xC6
        #define KEY_F6 0xC7
        #define KEY_F7 0xC8
        #define KEY_F8 0xC9
        const byte ROWS = 8;
        const byte COLS = 8;
        uint8_t keys[ROWS][COLS] = {
        {'1','3','5','7','9','+',KEY_POUND, KEY_DELETE},
        {KEY_TAB, 'w','r','y','i','p','*', KEY_RETURN},
        {KEY_LEFT_CTRL, 'a','d','g','j','l',';', KEY_RIGHT_ARROW},
        {KEY_ESC, KEY_LEFT_SHIFT, 'x','v','n',',','/', KEY_DOWN_ARROW},
        {' ','z','c','b','m','.', KEY_RIGHT_SHIFT, KEY_F1},
        {KEY_LEFT_ALT, 's','f','h','k',':','=', KEY_F3},
        {'q','e','t','u','o', KEY_AT_SIGN, KEY_PAGE_DOWN, KEY_F5},
        {'2','4','6','8','0','-', KEY_HOME, KEY_F7}
        uint8_t shiftkeys[ROWS][COLS] = {
        {'!', KEY_HASH,'%', KEY_APOSTROPHE,')','+', KEY_POUND, KEY_INSERT},
        {KEY_TAB, 'W','R','Y','I','P','*', KEY_RETURN},
        {KEY_LEFT_CTRL, 'A','D','G','J','L',']', KEY_LEFT_ARROW},
        {KEY_ESC, KEY_NULL, 'X','V','N','<','?', KEY_UP_ARROW},
        {' ','Z','C','B','M','>', KEY_NULL, KEY_F2},
        {KEY_LEFT_ALT, 'S','F','H','K','[','_', KEY_F4},
        {'Q','E','T','U','O', KEY_AT_SIGN, KEY_PAGE_UP, KEY_F6},
        {KEY_QUOTE, '$','&','(','0','-', KEY_END, KEY_F8}
        byte rowPins[ROWS] = {4,5,6,7,8,9,10,11};
        byte colPins[COLS] = {A5,A4,A3,A2,A1,A0,2,3};
        Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
        unsigned long loopCount;
        unsigned long startTime;
        String msg;
        void setup() {
        loopCount = 0;
        startTime = millis();
        msg = "";
        bool killLoopFlag = false;
        void loop()
        char c, dspbuf[32];
        if (!killLoopFlag)
        if (Serial.available())
        c =;
        if ((c == 'q') || (c == 'Q'))
        killLoopFlag = true;
        if ( (millis()-startTime)>5000 )
        Serial.print("Average loops per second = ");
        startTime = millis();
        loopCount = 0;
        // Fills kpd.key[ ] array with up-to 10 active keys.
        // Returns true if there are ANY active keys.
        if (kpd.getKeys())
        for (int i=0; i<LIST_MAX; i++) // Scan the whole key list.
        if ( kpd.key[i].stateChanged ) // Only find keys that have changed state.
        sprintf(dspbuf, "Key 0x%02X ", kpd.key[i].kchar);
        switch (kpd.key[i].kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
        case PRESSED:
        msg = " PRESSED.";
        strcat(dspbuf, " PRESSED");
        case HOLD:
        msg = " HOLD.";
        strcat(dspbuf, " HOLD");
        case RELEASED:
        msg = " RELEASED.";
        strcat(dspbuf, " RELEASED");
        case IDLE:
        msg = " IDLE.";
        strcat(dspbuf, " IDLE");
        // sprintf(dspbuf, "Key 0x%02X %s", kpd.key[i].kchar, msg);
        // Serial.print("Key ");
        // Serial.print(kpd.key[i].kchar);
        // Serial.println(msg);
        } // End loop


        Answer 1 year ago

        Hi Kerry
        I've tried the code you provided and it works well for me. I tried all keys on the matrix. If you're using the same keypad library (v3.1.1), then I guess the wiring would be the next place to check. I've got two C64s and micros on this pinout mapping, which I checked in the article just in case ... Failing that, then if you've got another Arduino, that would be worth a try. Maybe the C64 keyboard is faulty but I'm not sure how that would reset the micro. Good luck - let me know how you go?


        Reply 1 year ago

        Thanks for your testing and reply. I have tried this on both an Arduino Micro and NANO. When I had the row on pin 11 (as in your article) and I hit any of those row keys... the micros would reset. I moved row 7 to pin 12 and put the RESTORE key on pin 11. Problem went away. Of course, if I hit the RESTORE key, the micro resets. So, either the issue is how pin 11 is setup by the Keypad code or ... Anyway, I've worked around it. Thanks for your help and the article. I'm actually 3D printing side and back panels for the Pi and ports to be accessed. I'll shoot you a pic when done. Regards


        Reply 1 year ago

        A bit puzzling but good to hear your problem has mostly been resolved with the workaround. I would be interested to see your 3D printed results! My brother has created some 3D prints (he has the other C64 I mentioned) and the results are very professional looking. I've also got a PCB for the keyboard now, pic below. Might be an option for your set-up?


        1 year ago

        Wow. I still have my Commodore 64 but I'd need some assistance for this build. Impressive :)


        1 year ago

        Wow great project! A lot of time must have been put in to this, looks a lot of fun with the old games!


        1 year ago

        Nicely put together project and ‘ible.

        I look forward to seeing your PCB solution to replace the breadboard.


        1 year ago

        All this project is it available for amstrad 6128?
        Does anyone know positive?
        I have one in the ground floor...


        Reply 1 year ago

        You make me happy my friend


        Reply 1 year ago

        The Amstrad 6128 also has a matrix style keyboard and the documents
        for it are on-line so I think with a bit of tinkering with the Arduino code and
        jumper connections you should have a decent chance of getting that to work


        1 year ago

        I have been looking at a similar solution, but run into a problem that RetroPi + Vice doesn't want to drop you into the basic prompt. IMHO nostalgic value would increase if it would do the following:
        * Start Vice directly at boot of the PI
        * Make Vice start with the basic prompt by default.

        Does anyone know how to do that?


        Reply 1 year ago

        I’ve not tried this myself but instead of RetroPie, it might
        be worth looking at Combian 64
        It boots into VICE. To get the VICE settings and to load the games, pressing
        the Control key and F7 on my Commodore build (which is F12) should get you


        Tip 1 year ago on Step 17

        I admire the complete build, but I foresee a power issue in the Micro USB port in step 12. I strongly recommend upgrading to a USB type C port, which is very common now for Samsung and Apple products, has no issue if the plug is inserted upside down, and can carry over 5 amps (25 Watts) of power. After replacing many Micro USB ports in laptops, smartphones, and even Chromebooks, I know that the USB type C port is the much better power option.


        Reply 1 year ago

        Thanks for the tip. I might add a USB hard disk inside the Commodore which needs
        a powered USB hub, so will look at USB-C port for that connection