Making an arcade-style custom controller

Posted on
  • Hey there!
    I ordered the Espruino Pico via Kickstarter a while ago, without much thinking of what I could do with it. I make video games as a hobby, and now I want to use my pico to make a custom controller. Since this is my very first hardware project (except for some soldering back in school...), I have a few questions:

    The Pico has 22 GPIO pins (9 Analogs inputs, 21 PWM, 2 Serial, 3 SPI, 3 I2C), does that mean I can use a total of 22 Buttons? Or are some of those not suitable for generic Buttons?
    What if I wanted to add more Buttons? I thought about supporting up to four players, with one D-Pad (4 pins) and 4 Buttons per player, but then I would need at least 32 pins.

    I plan to use some of these buttons and these Joysticks, which apparently behave just like a 4-button-entity.

    Thanks in advance :)

  • Wow, that's a great idea! What type of computer are you planning on connecting it to? Currently the Pico can pretend to be a Keyboard on Mac, Android and Linux really well, but Windows doesn't pick it up. That'll be fixed in some future firmware update though.

    But otherwise, yes - you can connect a button to each GPIO pin, but you can go one better. You can 'matrix' the buttons - you basically wire them up in a grid, with rows connected to one side of the buttons, and columns to the other (obviously they don't actually need to be physically arranged in a grid - just wired that way). It's what keyboards do, and means that with N + M wires, you can connect N * M buttons. So with 22 wires you could manage 11*11 = 121 buttons :)

    There's actually a library to handle it nicely: http://www.espruino.com/KeyPad

    The only thing to watch out for is that if multiple buttons are pressed at once, it can get confused. As you're making an arcade controller that's a real possibility, so you can put one diode on each button - there's an article on it here: https://electrosome.com/reading-multiple­-pressed-keys-matrix-keypad-pic-microcon­troller/

    I don't think it actually makes any different to how your read the data, it just means you don't get 'ghost' keys pressed.

    ... the buttons you posted links to look like they'd be fine though.

    Hope that helps!

  • I'm going to use it for the Ouya, which runs Android, and had no problems with a standard USB mouse or keyboard, so I hope it won't be a problem :).
    The matrix-wiring is exactly what I was looking for! That way, I can actually give each player a few more buttons.
    Thanks for the quick reply!

  • No problem - it'll save you a lot of pain when wiring up too. There will be significantly less wires involved!

    With the diodes, totally bog standard cheap ones will do. And you can solder them right onto the metal 'tab' sticking out of the switch, so it won't really be much more difficult to add them.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Making an arcade-style custom controller

Posted by Avatar for Mirko @Mirko

Actions