The Grand Central comes preloaded with CircuitPython. CircuitPython allows you to program a wide variety of microcontroller boards and single board computers without installing software on your computer. All you need is a plain text editor, found on all computers since before IBM made the PC.

If you would like a Python-friendly editor which has a serial connection to the board, a plotter, and more, Adafruit recommends Mu, a free editor made for ease of use. See this page on installing Mu if you like.

Download Library Files

Plug your Grand Central board into your computer via a USB cable. Please be sure it is a good power+data cable so the computer can talk to the Grand Central board.

A new disk should appear in your computer's file explorer/finder called CIRCUITPY. This is the place we'll copy the code, sound files, and code libraries.

Create a new directory on your Grand Central's CIRCUITPY drive named lib.

Download the latest CircuitPython drivers to your computer using the green button below. Save to your computer's hard drive where you can find it.

With your file explorer/finder, browse to the bundle and open it up. Copy the following file from the library bundle to your CIRCUITPY lib directory you made earlier:

  • adafruit_matrixkeypad.mpy

All of the other necessary code is baked into CircuitPython!

Download Code and Sounds

Below is the code for this project. To grab the entire package with the sample train sound files, select Download: Project Zip to your computer hard drive. This will contain and a subdirectory called sounds which contains the wav files.

With your computer file explorer/finder, browse to the location where you saved the code zip file, open the zip file, open the folder Grand_Central_Soundboard directory and copy the files and the sounds directory to your CIRCUITPY drive. The sounds directory will contain 8 wav files and a license text file.

# SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import os
import digitalio
import audioio
import audiocore
import board
import adafruit_matrixkeypad

# Membrane 3x4 matrix keypad -
cols = [digitalio.DigitalInOut(x) for x in (board.D3, board.D2, board.D1)]
rows = [digitalio.DigitalInOut(x) for x in (board.D7, board.D6, board.D5, board.D4)]

keys = ((1, 2, 3),
        (4, 5, 6),
        (7, 8, 9),
        ('*', 0, '#'))

keypad = adafruit_matrixkeypad.Matrix_Keypad(rows, cols, keys)

wavefiles = [file for file in os.listdir("/sounds/")
             if (file.endswith(".wav") and not file.startswith("._"))]
if len(wavefiles) < 1:
    print("No wav files found in sounds directory")
    print("Audio files found: ", wavefiles)

# audio output
gc_audio = audioio.AudioOut(board.A0)
audio_file = None

def play_file(filename):
    global audio_file  # pylint: disable=global-statement
    if gc_audio.playing:
    if audio_file:
    audio_file = open(filename, "rb")
    wav = audiocore.WaveFile(audio_file)

while True:
    keys = keypad.pressed_keys
    if keys:
        print("Pressed: ", keys)
        button = keys[0]
        if button > 0 and button < 9:
            soundfile = "/sounds/0"+str(keys[0])+".wav"
        if button == 0:
            if audio_file:

Coding the project in CircuitPython makes this project truly easy. Copy the code and go! You can see the libraries that facilitate using the Grand Central and the matrix keypad are already coded - the program defines what we're using (keypad, audio), grabs the sound files, then checks to see when you press a key to trigger the appropriate effect.

Files Double Check

A listing of the CIRCUITPY drive in your file explorer/finder should look similar to the one below. The extra files starting with a period (if you see them) are for Mac file handling, you don't need to deal with those. You should just ensure you have, a sounds directory (containing wav files) and a lib directory containing the matrix keypad library.

On your Grand Central CIRCUITPY flash drive, if you are missing the, the lib directory or the sounds directory (with the respective files in the directory files), please go back and download them. They'll all be needed for the final project.

This guide was first published on Jan 16, 2019. It was last updated on Jun 11, 2024.

This page (Software) was last updated on Jun 11, 2024.

Text editor powered by tinymce.