Curious if I can use Teensy to do something with this joystick and roller ball

Status
Not open for further replies.

p_wats

New member
Long story short, I bought a Teensy++ 2.0 to build a midi foot pedal to use with my Synthstrom Deluge, but ended up buying the pedal they made specifically for it. Now I have a Teensy to use for something else.

I'm new to this sort of development, but used to be a front end dev and am not scared of code, so I'm curious if I can do something fun with some weird controller/arcade pieces I have lying around.

The first is a simple joystick that connects two pins when pressed in a particular direction. I imagine it would be simple enough to code these as 4 different momentary buttons (one for each direction), but I wonder if I could keep the button "firing" as long as I was pressing the joystick (ie, as long as the connections in one direction stayed closed). Could be useful for zooming, scrolling, etc.

20191016_163017.jpg

The second is more complex, as it looks like a roller ball for a more involved setup. It has 15 connections, but seems like many of them are spare according to the data sheet (http://www.beisensors.com/pdfs/tbs11.pdf).

20191016_163040.jpg

I'm basically trying to decide a) if these parts are useful to work with and b) if there's something fun I can do with the Teensy, since I no longer need it for a specific foot switch.

All thoughts or pointers are welcome---I expect this to be a lot of learning and no need to rush results (already installed Teensyduino, etc. on my PC). Thanks!
 
The first is a simple joystick that connects two pins when pressed in a particular direction.
This looks very similar to standard arcade joystics people use with Teensies,
480-01.jpg

The only difference is that the newer arcade joystics use microswitches instead of plain leaf connections -- but microswitches are really just enclosed similar contactors, so it's not even a real difference.
The transparent plastic thingy near the bottom is a replaceable "limit" disk, that restricts how far the stick can move in each direction.
This has only five pins, because the "input" side of each of the four contactors is commoned to the fifth pin, simply for ease of use. You can do the same for yours.

I wonder if I could keep the button "firing" as long as I was pressing the joystick
Yes, that is how it is done by default. Essentially, the USB HID (Human Interface Device protocol) provides one "event" when the button closes, and another when it opens.

(Oh, except for Joysticks: they have a set of bits corresponding to firing buttons, that is sent with each event, including whenever a firing button closes or opens, or any of the joystick axis positions change.)

The second is more complex
Happily, no. It is just two (incremental, quadrature) rotary encoders. You connect its pin 15 to +5V, pin 13 to GND, pins 5 and 6 to one pair of GPIO pins for one rotary encoder, and pins 7 and 8 to another pair of GPIO pins for the other rotary encoder.

All you need is already in Teensyduino, so if you are careful to check the wiring so you don't do short circuits (I'm clumsy :eek:), you're good to go!

Use the USB Keyboard and/or USB Joystick examples, as a basis, and the Encoder library (it is included in Teensyduino) to read the two trackball encoders (one per axis).

My first microcontroller project was an arcade-style joystick and button board, that emitted keyboard keypresses, so I could play Flash puzzle platform games online with it. And SuperTux.
 
This looks very similar to standard arcade joystics people use with Teensies,
480-01.jpg

The only difference is that the newer arcade joystics use microswitches instead of plain leaf connections -- but microswitches are really just enclosed similar contactors, so it's not even a real difference.
The transparent plastic thingy near the bottom is a replaceable "limit" disk, that restricts how far the stick can move in each direction.
This has only five pins, because the "input" side of each of the four contactors is commoned to the fifth pin, simply for ease of use. You can do the same for yours.


Yes, that is how it is done by default. Essentially, the USB HID (Human Interface Device protocol) provides one "event" when the button closes, and another when it opens.


Happily, no. It is just two (incremental, quadrature) rotary encoders. You connect its pin 15 to +5V, pin 13 to GND, pins 5 and 6 to one pair of GPIO pins for one rotary encoder, and pins 7 and 8 to another pair of GPIO pins for the other rotary encoder.

All you need is already in Teensyduino, so if you are careful to check the wiring so you don't do short circuits (I'm clumsy :eek:), you're good to go!

Use the USB Keyboard and/or USB Joystick examples, as a basis, and the Encoder library (it is included in Teensyduino) to read the two trackball encoders (one per axis).

My first microcontroller project was an arcade-style joystick and button board, that emitted keyboard keypresses, so I could play Flash puzzle platform games online with it.

Oh wow. That is very helpful! Thanks. I'll do some digging and mess around a bit.

Glad to hear that ball encoder may still be useful. I'm not entirely sure if it even works, as it was given to me by a friend in a box of other random bits, but worth a shot.

It's possible I shorted it out already, as I noticed the pinout on the breakout cable does not actually match the connections on the board (they are reversed), but we'll see.

Thanks for the help!
 
It is not the trackball I would worry about for shorts -- it is likely just a couple of photointerruptors (ie. LEDs and phototransistors) with a disk with holes or windows rotating in between, so it isn't very sensitive to goofs.

I was referring to stuff like setting a Teensy pin as output, but then shorting it to ground. I use a cheap multimeter to check my wiring for such, as it is too easy to burn out a Teensy pin doing that.

You can use say 1kOhm resistors, connected to each Teensy GPIO pin, between the pin and the switch, to limit the maximum current through that pin (to 5 mA at 5 V), or even 10kOhm (for 0.5mA at 5V). The trackball might have such resistors built-in. Without a resistor, an output pin connected directly to ground tries to carry as much current as is available, which is too much for the pin circuitry to handle, and tends to burn it out. Many Arduino tutorials talk about this better than I can.

Of course, if you double-check your code and wiring (especially when configuring pins as outputs), those resistors are not needed. I sometimes use them to shield myself from the worst effects of my own errors, that's all.
 
It is not the trackball I would worry about for shorts -- it is likely just a couple of photointerruptors (ie. LEDs and phototransistors) with a disk with holes or windows rotating in between, so it isn't very sensitive to goofs.

I was referring to stuff like setting a Teensy pin as output, but then shorting it to ground. I use a cheap multimeter to check my wiring for such, as it is too easy to burn out a Teensy pin doing that.

You can use say 1kOhm resistors, connected to each Teensy GPIO pin, between the pin and the switch, to limit the maximum current through that pin (to 5 mA at 5 V), or even 10kOhm (for 0.5mA at 5V), to avoid that. Without a resistor, an output pin connected directly to ground tries to carry as much current as is available, which is too much for the pin circuitry to handle, and tends to burn it out. Many Arduino tutorials talk about this better than I can.

That is very helpful. Thanks! I build pedals, etc. but haven't worked with Arduinos or the like before. I'll dig around on this a bit too to make sure I don't make a silly mistake.

Trying to figure out what I'd actually program the trackball to do musically...I'm sure I'll think of something.
 
Status
Not open for further replies.
Back
Top