ButtonBox with PiFace Digital

Difficulty: easy

Keyboards are boring - we want big buttons that say ‘press me’ and light up and flash just like real arcade games, and here's how to do it.

Arcade buttons with PiFace Digital

Arcade buttons come in many shapes and sizes, but most have similar parts. They consist of a plastic plunger, a light so they glow, and a switch (specifically called a microswitch) to register when they have been pressed.


Microswitches are commonly used as they are small, robust and cheap. Just like any other switch they can complete a circuit (allowing electricity to flow) when pressed. However, they’re more flexible as they can also be wired to break a circuit when pressed. As such there are three connectors and you need to use the correct pair. Look closely at the switch and you should see the following labeled pins:

  • Common (COM.) - pressing the button changes the connection of common from one pin to the other
  • Normally Open (N.O.) - which means when the button is pressed, this pin is connected to COM.
  • Normally Closed (N.C.) - which means when the button is pressed, this pin is not connected to COM

Note: If your switch only has two pins don’t worry it’s probably not got a N.C pin. Also, if you can’t see the labels then use a multimeter or create a simple circuit, and try all connections until you discover which pins become connected when pressed.

For the majority of purposes you will use the COM. and N.O. pins to complete the circuit when the button is pressed. If you want the circuit to be broken when pressed, use the N.C. pin instead of the N.O. pin.


The lights in your arcade buttons can be used in many ways in your games, for feedback to notify the player a button has been pressed, or as a cue for the player to press the button. Historically arcade buttons had filament lamps which got hot and would wear out. However, modern versions have LEDs. LEDs have advantages over traditional bulbs, in that they are more efficient and have longer life. However there are a couple of things to note:
  • LEDs must be wired up the right way round or will not work.
  • LEDs can be damaged by too much voltage.

Luckily the LEDs that come with arcade buttons are usually suitable for use with the 5V supplied by PiFace, and have clear + and - markings to show which terminal should be connected to the 5V.

Wiring the arcade buttons

Follow the steps below to wire up your arcade buttons. If you are not using arcade buttons, use separate LEDs and switches, and place them near each other.

  • On your arcade button, connect the pin labelled N.O. to an input on PiFace Digital. Repeat this step for each of your arcade buttons, wiring them each to a different input pin on PiFace Digital.
  • Wire the COM. connectors of your buttons together and connect them all to the GND terminal, (to the right of the input pins).
  • The LEDs in your buttons will have two connectors. Wire all the positive (+) connectors together, and connect them to 5V on PiFace DIgital.
  • Wire the each LED’s negative (-) connector to a different output pin on the PiFace Digital. Connect the LED to the output pin corresponding to the input pin the switch is connected to.
  • If you are not using 5v LEDs you will need to connect a resistor for each LED. To do this:
    • Cut the wire connected to the LED’s negative
    • strip the two ends that are created
    • twist together, (or solder) the wire ends, one to each end of the resistor.
    • Repeat for each LED you are using.
WARNING: To avoid burning out your LED you may need to attach a resistor to it. The value of the resistor will vary depending on your LED, but for the most common LEDs with 5V a 560 Ohm resistor (Green-Blue-Brown) will work.


It is best to test your buttons at this point, as if there are problems with your wiring, you might not know if it’s the buttons or the code that isn’t working properly. Use the emulator to test the buttons and LEDs, like this:
  • For the emulator to work you must be in the graphical environment. If you are not, do this with the command
    And start the emulator by typing the following command in a Terminal
    The emulator will appear.
  • Enable>Output Control must be checked on the emulator, to be able to turn on outputs.
  • Turn the LEDs on individually using the buttons on the emulator.
  • Press your arcade buttons individually* and check the emulator has registered the input. * Testing them individually allows you to check you haven’t got short circuits -- else you wouldn’t know if you had a fault that would mean two outputs came on together or two inputs registered at once.