Which Teensy to use for a 14 buttons + 2 joysticks USB game controller ?

Status
Not open for further replies.
Hello,

I would like to build a USB Game Controller using a Teensy, to use it with a Raspberry Pi on a handheld retro console.

The controller will have 14 buttons, using momentary push buttons :
  • A, B, X, Y
  • START, SELECT
  • LT, RT, LB, RB
  • DPAD UP, DOWN, LEFT, RIGHT

And 2 joysticks, from what I understood each has 2 analog pins (X and Y axis).

That makes a total of 14 push buttons, and 4 analog. From what I've read, the push buttons can be used with either digital or analog inputs, but the joysticks obviously need analog inputs.

I would like to fit everything on a single Teensy to make a "standalone" controller (self-powered via USB, so I'll be using the 3.3v pins of the board), working on Windows for testing and eventually the Raspberry Pi (and maybe other devices too). The code will be a simple loop where I check for each pin and send them as joystick buttons / axis via USB.

Now here is my question : which Teensy should I buy ? Will a Teensy 3.2 be enough for that ? Will it have enough pins, and of the right type ? I also want to add VOL-, VOL+ and MENU buttons but I need to emulate a keyboard for them, so I'll wire them directly to the Raspberry Pi (unless the Teensy has enough pins AND the capability to emulate both a USB keyboard and joystick).

Thanks for the input :)
 
You could do it with any of the ARM based Teensys (LC, 3.2, 3.5, or 3.6). On the Teensy LC/3.2, you have the following pins that can be used on the outer rows of pins that are easily used in a breadboard or soldered to a pcb:
  • 13 digital input/output pins;
  • 1 pin that can only do digital output (13), and is hooked up to the on board LED;
  • 10 pins that can be either digital or analog;
In addition, there are 2 analog input pins and 1 analog input/output pin that can be used for sound output with easily accessible soldering holes inside of the Teensy.

On the Teensy 3.5/3.6, you have 7 more digital only pins along the main breadboard row and 9 more digital/analog pins.

In addition, on the Teensy 3.2/3.5/3.6, there are more pins available if you solder wires to the solder pads underneath the Teensy.

If I may make a suggestion on which pins to use, you might want to not use pins 18/19 (A4/A5). These pins are the I2C pins. With two 2.2k resistors soldered between each of the pins and 3.3v, you can add various simple devices to the Teensy, such as extenders for reading additional digital pins, simple displays, etc. If you want to add more digital inputs or outputs, the MCP23017 (https://www.adafruit.com/product/732) can be added to the i2c bus to support 16 digital input/output pins (and you can hook up to 8 MCP23017's on a single i2c bus). You might not need this now, but it is useful to plan for growth.
 
Last edited:
Teensy LC should be able to do all this. Yes, it can even do the USB keyboard emulation for those media control buttons, while doing the USB joystick stuff.

After you install Arduino+Teensyduino, in Arduino select Teensy LC from Tools > Boards. Then use File > Examples > Teensy > USB_Joystick to get started. There's also an example for the media buttons in File > Examples > Teensy > USB_Keyboard. Those should give you most of the code you need.
 
Thanks for all your answers !

I might go with the Teensy LC because, well, it's low cost compared to the 3.2. I'll use the 13 digital pins for the 13 first buttons, 4 digital/analog pin in D mode for the remaining buttons and 4 digital/analog pins in A mode for the joysticks.

I just installed the Arduino IDE and Teensyduino, and I saw the Keyboard + Mouse + Joystick USB type... I think that'll do !
 
Thanks for all your answers !

I might go with the Teensy LC because, well, it's low cost compared to the 3.2. I'll use the 13 digital pins for the 13 first buttons, 4 digital/analog pin in D mode for the remaining buttons and 4 digital/analog pins in A mode for the joysticks.

I just installed the Arduino IDE and Teensyduino, and I saw the Keyboard + Mouse + Joystick USB type... I think that'll do !

Were you able to get this working? I am working on a very similar project. I would be interested in your code if you are willing to share it.

Using a Teensy 3.2 I am able to get 1 Joystick and some buttons work very easily. I am stuck on adding the second Joystick.

I was looking at the properties of an Xbox controller and it appears the right joystick controlls X and Y rotation. I am not sure how to write code for that though (arduino noob).

Any help would be appreciated!
 
<strike>Thanks for sharing!

In your pinout mapping I see that the right joystick is pinned to A6 and A7.

I don't see any mention of those in your code though, and after uploading to my teensy it doesnt appear that manipulating the right joystick does anything. :confused:</strike>

Nevermind! I figured it out!

I added..

Code:
void joystick_z(unsigned int value)
{
  Joystick.Z(value);
}

void joystick_zr(unsigned int value)
{
  Joystick.Zrotate(value);
}

And

Code:
{A6, A7, joystick_z, joystick_zr} //Right analog

It works! Thanks again for sharing.
 
Joystick only registering two directions

Sure, here is my code : https://github.com/natinusala/Retro...tch/blob/master/retromachine/retromachine.ino

edit: and here is the button & pinout mapping : https://puu.sh/Cz96h/ec62d7557a.png

DX is digital pin X, ADX is analog or digital pin X, (D) being in digital mode and (A) in analog mode

Hello I tried using your code but my joystick is only registering two directions, ie. Left and down the way I have it oriented in the case. When trying to configured in emulation station it reads 0+ and 1+ for those two directions. Any thoughts? Is it a faulty psp1000 joystick?
 
Where did you put the code exactly your code? If you don't mind me asking I just joined and I have a teensy LC. And are all your single buttons soldered to one ground wire?
 
Any Luck?

Hello I tried using your code but my joystick is only registering two directions, ie. Left and down the way I have it oriented in the case. When trying to configured in emulation station it reads 0+ and 1+ for those two directions. Any thoughts? Is it a faulty psp1000 joystick?

Wondering if you ever figured out what the problem was for you joystick. Only my up ( 1- i think) isn't working, and if replacing it was the fix for you id order a handful more.
 
Status
Not open for further replies.
Back
Top