Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

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

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    3

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

    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.

    Click image for larger version. 

Name:	20191016_163017.jpg 
Views:	4 
Size:	52.1 KB 
ID:	17945

    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).

    Click image for larger version. 

Name:	20191016_163040.jpg 
Views:	3 
Size:	65.7 KB 
ID:	17946

    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!

  2. #2
    Senior Member
    Join Date
    Feb 2015
    Location
    Finland
    Posts
    128
    Quote Originally Posted by p_wats View Post
    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,

    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.

    Quote Originally Posted by p_wats View Post
    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.)

    Quote Originally Posted by p_wats View Post
    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 ), 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.

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    Quote Originally Posted by Nominal Animal View Post
    This looks very similar to standard arcade joystics people use with Teensies,

    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 ), 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!

  4. #4
    Senior Member
    Join Date
    Feb 2015
    Location
    Finland
    Posts
    128
    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.

  5. #5
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    Quote Originally Posted by Nominal Animal View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •