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

Thread: Teensy LC and PiGrrl PCB

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    7

    Teensy LC and PiGrrl PCB

    I have a few questions. I think I'm in over my head.
    1. Can I wire a pigrrl2 PCB board to the TeensyLC. If so do I have to solder each button? Can I solder the 5V pad to the 3.3V on the TeensyLC?
    2. do I have to write a special code for the pigrrl PCB to interact with the two thumb sticks and the extra 2 buttons for second set of shoulder buttons?

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,887
    It might help if you include a link to the PCB board and possibly other documentation in your questions.

  3. #3

  4. #4

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,887

    Cool

    I suspect it may be complex for a complete beginner.

    The PCB itself is fairly simple. There are 10 buttons that need to be soldered in. These buttons connect to specific pins in the 2x20 pin array that form the standard Raspberry PI pinout. The standard Teensy pinout is completely differ.

    You would have to translate the Pi code to Teensy code, and map the Pi pins to the Teensy pins and then solder in jumper wires to connect the two sets of pins.

    This is where the main tricky part is. Ideally, you should be familiar with both programming on the Pi and programming on the Teensy to do this transformation. And if you want to do graphics or audio it will be even worse. Things are completely different between the two systems. It can be done, but essentially, you will be completely completely rewriting the program, using the Pi program as a template. And note, the LC has very little memory compared to the Raspberry Pi. It may be the program is too large for the LC (or maybe it will fit just fine).

    There are 4 additional connections for the audio. While the Teensy LC has a DAC (digital -> analog) port that can be used for audio. Unfortunately the Teensy LC does not have support for the Teensy Audio Library. If you wanted to play simple sounds there are ways to do it on the Teensy, but ideally you would want to step up to at least a Teensy 3.2 if you wanted to play audio.

    Speaking of audio and graphics, the Raspberry Pi has a filesystem on its micro-SD card, and programs generally keep the graphics/audio files there. The Teensy LC does not have a micro-SD card, but you can attach one if needed. But that is more programming.

    What the PCB does is just give you buttons in the position of a different controller. It may be better to not worry about getting the shape of the controller right immediately. Instead, put the buttons on a breadboard, and use that as you are coding. Then when you have the program working, you can integrate the PCB.

    Or possibly step back, and take stock of what you want to do. Maybe using the Pi will do what you want faster than the Teensy. Maybe doing something else on the Teensy will work. You can keep using the PCB as the end goal, but you want to have smaller achievable steps in between.
    Last edited by MichaelMeissner; 10-13-2020 at 04:17 AM.

  6. #6
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,887

    Cool

    If you have some skill in soldering perhaps using the Adafruit feather wing system might give you some results more quickly.

    For example, if you have the following, you can put them together and have a small display, joystick, and 2 buttons. I would suggest using the Teensy 3.2 instead of the LC, just because it has more memory, and the audio library will work if you wanted to add sounds down the road. Note, you would need to do some adaptations if you use the Teensy 3.5, 3.6, 4.0, or 4.1:


    Instead of the unit with a combined display (and only one joystick + 2 buttons), you could go with the joystick feather wing which has a 5 axis joystick and 5 buttons:


    If you wanted to combine it with a display, I kind of like the Feather tripler:


    But at the end of the day, perhaps for starting out, maybe something self contained like the PyGamer Starter kit would be good to get your feet wet (obviously this is not a Teensy inside):

  7. #7
    Junior Member
    Join Date
    Oct 2020
    Posts
    7
    I appreciate the time and your knowledge. Basically what I was trying to do as an alternative is wire the PCB board to the pi4. Afterwards wire the two thumb sticks to the TeensyLC along with two extra shoulder buttons. Use the TeensyLC as a USB controller plugged into the pi4. This I would think would be a complete controller. Or is it more complex than this?

  8. #8
    Junior Member
    Join Date
    Oct 2020
    Posts
    7
    As far as audio and screen, I have a 5in screen already thats plug and play. USB for touch, HDMI to micro HDMI. It also has sound so I thought that would be straight forward.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,069
    Teensy certainly can act as a USB keyboard, mouse and joystick. To see how you would do this, install Arduino & Teensyduino. You can get the software here.

    https://www.pjrc.com/teensy/td_download.html

    Even if you don't have a Teensy yet, you can install the software and look at the example code for making buttons work as a joystick or keyboard. Just opening the code will give you some idea of what you'll be working with, so you can gauge whether it will meet your needs and what sort of experience to expect in crafting your project.

    After you install, run Arduino and select any Teensy board from the Tools > Boards menu. This step matters, because Arduino's others menus dynamically update depending on the selected board.

    Then click File > Examples > Teensy > USB_Joystick > Buttons, or click File > Examples > Teensy > USB_Keyboard > Buttons. These will show you sample code which runs on Teensy and monitors the pins for changes from the buttons, and transmits USB data to your PC (or the Raspberry Pi) when the button changes are detected.

    These are just examples. You can copy or write mode code into them, or delete parts you don't need. The idea is loop() keeps running over and over, each time checking whether inputs have changed and transmits the needed messages when they do. You could have Teensy be both a keyboard and a joystick. But whatever you do, this sort of coding is how you will make Teensy actually do the things you want.

Posting Permissions

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