I just got my first arduino card - a Teensy 3.2 and this is really fun!
I bought an joystick to try to make my own controller and I almost got there, just 2 issues:
When I press FORWARD on the joystick - I run backward in game, and when I press the joystick BACK it run forward... Is it possible to revert this by coding? I know I hold the joystick the correct way - since right and left is correct.
Is it an easy way (already exist?) code to turn the joystick into WASD keys? Actually I found some code to do this already, but I also want it to be 8 way WASD.. Like if I press the joystick between forward and right it should press [WD] and not only [W] or [D]. And so on for the other "middle" corners.
Yes, that's totally possible. How depends on the code you haven't shown, the joystick you haven't described, and the rest of the setup that you haven't mentioned.
That's doable. Depends on which type of Arduino you have and whether or not it can act as a keyboard. I don't know about the Teensy 3.2 but I do know that the Leonardo can do this.
The teensy card can act as a keyboard. I already tryed to connect buttons to it, which send letters. I also managed to make the joystick send 'W', 'A', 'S' and 'D'.. But the difficult part is when the joystick is between the letters - i want it to send for example 'WD' together..
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
You will only need to change some connections to your joystick, but we need to see your circuit diagram.
Thanks for the image, you will need to change some code to change the direction of the joystick.
Which input on the Arduino is the input from the reversed axis?
So I made your program a lot longer. Twice the length, due to adding several blank lines. It really helps readability to add some space around units of code.
I named all the pins and intermediate variables. Now it is easier to see what is a pin number and what is an input or output.
The Arduino map() function is perfect for turning an input into an output.
Keyboard coming next but I have to go away and re-read the documentation.
So I made your program a lot longer. Twice the length, due to adding several blank lines. It really helps readability to add some space around units of code.
I named all the pins and intermediate variables. Now it is easier to see what is a pin number and what is an input or output.
The Arduino map() function is perfect for turning an input into an output.
Keyboard coming next but I have to go away and re-read the documentation.
Great! This worked perfectly and fixed the forward/back -issue. Thanks a bunch Looking forward for the keyword part aswell.
Note there's no special case for diagonal movements. If you go left and up then it will hold down left (A) and then up (W) and keep them held down until you move the stick back to the middle.
I have not tested this. I don't know what the keyboard library will do with 20000 "press" events per second. I expect it will be fine because it doesn't actually send events over the USB wire that often.