Peuchele bio photo


Pedí pollo que yo pago la diferencia!


Do you have a spare Teensy 3.0, like I did, and you want to (under) use it? this might be a good one-afternoon DIY project: an Arcade Joystick.

Besides the ARM powered board, you will need a 4-switch arcade joystick, buttons, and a box that you need to still from your wife.

The firmware emulates an USB keyboard, so all you have to do is connect the switches from the stick and the buttons to the teensy digital inputs. No other external components are needed. For convenience, I’ve used inputs 0 to 7. I’m using only 4 push buttons, but you can easily extend it if you want, just adjust the NUM_BUTTONS and the keys array accordingly.

Joystick switches emulates the arrow keys, and the buttons, well, you need to program them to whatever fits better for your games, in my case [Enter], [Space], [Left Alt] and [Z] did the trick for Super Frog HD. I should think in putting an internal switch to change the button’s configuration to something more standard like the MAME layout.

Just for reference, this is the list of materials I’ve used for this project:

Qty Name Link Price (U$S)
1 Teensy 3.0 19.00
1 4-Ways Red Ball Arcade Joystick with 4-Switch 11.55
4 Arcade Joystick Button and 3.59 each
1 Box -  

The Code

Of course, I am using the existing Teensy USB keyboard libraries, so the code is pretty simple – 32 lines of code.

/* Arcade Keyboard-Joystick */

#include <usb_keyboard.h>

#define NUM_BUTTONS 8
int mask = 0;
int i = 0;

void setup() {
	for (i = 0; i < NUM_BUTTONS; i++) {
		pinMode(i, INPUT_PULLUP);

void loop() {
	for (i = 0; i < NUM_BUTTONS; i++) {
		if (digitalRead(i) == LOW) {
			if (!(mask & (1 << i))) {[i] | (0x40 << 8));
				mask |= (1 << i);
		} else {
			if ((mask & (1 << i))) {
				Keyboard.release(keys[i] | (0x40 << 8));
				mask &= ~(1 << i);

See joystick.ino on gist

Connection Diagram

No explanation needed

Joystick Connection Diagram
Joystick Connection Diagram


Joystick connections Box holes Inside Joystick
Inside Joystick Joystick Joystick testing with uncle Alf