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

Thread: Gaming style controller

  1. #1
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23

    Gaming style controller

    I want to design a simple controller like device that is for gaming (guild wars 2-windows) This being that I want to have 21 tactile switch buttons (3 of the switches are foot pedals) and 2 analog joysticks with button click, just bought a teensy 3.1.

    Here's the things I want to know:
    -What type of coding does this device take (new to any type of coding, but willing to learn)
    -is there a power source needed for this type of project other than USB
    -any examples of pre-made code that I can utilize for a project like this

  2. #2
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Click image for larger version. 

Name:	gamingcontrollerHID (1).png 
Views:	246 
Size:	46.7 KB 
ID:	1231
    Thats the basic design so far, going to wire up the joys and what not, anything I'm missing please feel free to tell me.

  3. #3
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Click image for larger version. 

Name:	gameHID.jpg 
Views:	267 
Size:	141.1 KB 
ID:	1233 Somewhat of a finished design on breadboard

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,546
    How does the top pushbutton work? It's not wired the same way as all the others.

  5. #5
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    we talking about the joysticks? or the buttons on the breadboard? a cause they breadboard is wired pretty much all the same

  6. #6
    Senior Member
    Join Date
    Oct 2013
    Posts
    110
    Maybe he was referring to the fact that the first switch has a different pin tied to GND vs all of the others? if that switch's internals are what I think they are, you'd want wire the top-most resistor along the red line shown here:
    Click image for larger version. 

Name:	maybe_this.png 
Views:	188 
Size:	53.6 KB 
ID:	1234

  7. #7
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Quote Originally Posted by tetsuo View Post
    Maybe he was referring to the fact that the first switch has a different pin tied to GND vs all of the others? if that switch's internals are what I think they are, you'd want wire the top-most resistor along the red line shown here:
    Click image for larger version. 

Name:	maybe_this.png 
Views:	188 
Size:	53.6 KB 
ID:	1234
    Ah, well I'll wire it like you have it, just got lazy during the making up of the breadboard on fritzie, but yeah, all pins will end up the same, anything else as an issue on this board? still have to add a few things to it, but otherwise, its pretty much set, just awaiting my new headers in the mail.

  8. #8
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,248
    Note, if you use the INPUT_PULLUP mode for the buttons you can eliminate all of the resistors. You will need to reverse the sense of the test in the read (i.e. it returns LOW if the switch was pushed if you are using an input pullup, but it would return HIGH if you are using the resistor). Some people dislike that it inverts the test, but I prefer not to have to add extra resistors. If you are building it on a breadboard, there are some breadboards, where the power rails line up with the data pins, and you could connect one end of the switch directly to ground: http://arduino.cc/en/Tutorial/InputPullupSerial.

    Also, if you have lots of buttons, these buttons only take 2 0.1" rows instead of 3: http://www.adafruit.com/products/1489
    Last edited by MichaelMeissner; 12-19-2013 at 08:24 PM.

  9. #9
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Quote Originally Posted by MichaelMeissner View Post
    Note, if you use the INPUT_PULLUP mode for the buttons you can eliminate all of the resistors. You will need to reverse the sense of the test in the read (i.e. it returns LOW if the switch was pushed if you are using an input pullup, but it would return HIGH if you are using the resistor). Some people dislike that it inverts the test, but I prefer not to have to add extra resistors. If you are building it on a breadboard, there are some breadboards, where the power rails line up with the data pins, and you could connect one end of the switch directly to ground: http://arduino.cc/en/Tutorial/InputPullupSerial.

    Also, if you have lots of buttons, these buttons only take 2 0.1" rows instead of 3: http://www.adafruit.com/products/1489
    Genius, You now have turned me unto the colourful tact switches , also, I do not mind haveing all those resistors, works fine for what I want to do with them, they are only like 10kohms

  10. #10
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Final board picture
    Click image for larger version. 

Name:	gamingboard_bb.jpg 
Views:	228 
Size:	186.6 KB 
ID:	1236

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,546
    Yikes, that newest picture looks like it has GND connected to one side of each pushbutton and +3.3V power connected to the other side.

    Please DO NOT actually connect your wires this way.

  12. #12
    My custom gaming controller has 5 axis and 13 buttons. The code side is pretty easy thanks to a guide by FuzzieWuzzie. (When you go to his website, the guide is under programming)

    This is how I did mine..

    1. Played with the built in joystick demo to get a feel for the hardware side. Including testing the accelerometer hardware & joysticks.
    2. Used the guide above to create a custom HID controller and software.
    3. Design the physical parts, i.e. the case, button layout and wiring.


    The hardest part for my has been No 3, which maybe harder in my case as I am converting an existing device, meaning I am limited by space and button layout. No 1 is easy, just connect one side of the button to the teensy pin, the other to ground. For the joysticks connect one side of the pot to 3.3v, the other to agnd and the centre to the Teensy analogue pin. Using the internal pullups as suggested by MichaelMeissner, cuts down on components for one thing and will probably help with no 3. No 2 is much easier thanks to that guide, but I did struggle in a couple of places, just shout if you need help.

    Please note that although I have done 1,2 & 3 above I haven't actually got my project completed yet (mainly due to my crap soldering skills and the wrong choice of wire), so take this advice with a pinch of salt if you wish.

    Regards,

    Les

  13. #13
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Quote Originally Posted by PaulStoffregen View Post
    Yikes, that newest picture looks like it has GND connected to one side of each pushbutton and +3.3V power connected to the other side.

    Please DO NOT actually connect your wires this way.
    Why not? I see this example:

    http://arduino.cc/en/uploads/Tutoria...Control_bb.png

    And I figured I was doing it wrong from the get go, so I re-designed it after the example above.
    And there is only ground on one side of the buttons, not both sides...
    Last edited by ReonBalisty; 12-20-2013 at 03:54 PM. Reason: added information

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,546
    Quote Originally Posted by ReonBalisty View Post
    Why not? I see this example:
    That example does not short the power supply. Only the red wires connect to the buttons. The black wires do not connect to the pushbuttons. But on your most recent drawing, the pushbuttons do connect to both GND and VCC, which is a terrible mistake. Well, it would be terrible if you actually wire the parts that way and then press the buttons. No harm will happen if you fix it before physically building the circuit.

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,546
    The most common way to connect pushbuttons doesn't involve using VCC at all (the red wires) or any physical resistors. The chip has built-in resistors. You only need to type 7 extra characters to enable them. It's much easier to write pinMode(pin, INPUT_PULLUP) in your program than having to physically connect twice as many wires.

    Using the built-in resistors, all you need to do is connect one side of every button to GND, and the other side to the pin that reads it. That's so much easier. It also avoids running the GND and VCC wires all over the place, which is nice, since it those 2 every accidentally touch directly or through the metal contacts of a pushbutton, it's possible to damage your Teensy.

    Connecting the buttons this way causes the unpressed state to read as 1 or HIGH, and the pressed as 0 or LOW. That may seem backwards, but it's actually the most commonly used approach. It's called "active-low" and it's actually pretty much the standard way most electronics are designed. It's so common that many chips include internal pullup resistors, but not pulldown ones.

    The internal pullup resistors are already inside the chip. You already paid for them. Why not simply use them and reduce the amount of wiring by 50%?

  16. #16
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Interesting, will take that to the drawing board to revise, so all I need is output and GND, no need for VCC in this case except for joysticks? if so, saved me alot of wiring issues I was thinking about

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,546
    Yes, that's correct, VCC is not needed for pushbuttons.

    For more info and breadboard wiring photos, check this tutorial page and scroll down to "Built In Pullup Resistor"



    You can see the left pushbutton is connected with a resistor to VCC. The right one does the same thing, without needing the resistor and VCC connection. It's *much* simpler. Both work fine.

  18. #18
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Who would you recommend I go through for custom enclosures (might just go thrift hunting for cheap-o items to put my design in. the idea is to sit in your chair and play without the controller feel, basically mounted on the arm rests of computer chair.) and a custom PCB board?

  19. #19
    Member
    Join Date
    Dec 2013
    Location
    Magalia, CA
    Posts
    23
    Anyone able to help with how to code this, I'm stumped on how to start and all that jazz, is there a simplified way that I am missing? Thanks for your time guys

Tags for this Thread

Posting Permissions

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