Joystick / Controller #1647
Replies: 10 comments
-
Posted at 2016-10-27 by @gfwilliams If you want something that looks nice and is easy to wire up, the Wii Nunchuk could be a good idea: http://www.espruino.com/Wii Or are you after something much smaller? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-27 by @gfwilliams Also - if you have old PC joysticks (with the 15 pin D connector) then those are pretty easy to wire up. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by user69728 thank you, this is already helpful! while the Wii nunchuck is well documented, which modules / functions would I use to control a joystick? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by @allObjects 5 plain Buttons - not as elegant as joystick - will do just as well and are actually easier to program: setWatch(); and you have much more distinctive events. With ajoystick uou may need to poll - and depending the type of joystk - handle the analogue values yourself. @user697's suggestion to use a WII NUNCHUCK gives you much more dynamics that can outweigh the drawback of polling... dealing with the contiguous values requires much more logic though. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by user69728 thanks, got it. I found some documentation on two buttons, but still have no idea how to wire up several of them or a joystick. I think this is a common use case for projects: Do you know a similar detailed tutorial with example code and instructions how to wire it for a joystick? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by @allObjects Start with the Espruino Pico Button example... Btw, there are already several implementations of Tetris' on forum, for example, Tetris on RGB matrix. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by @gfwilliams I'd say:
Now, you could use setWatch to call when something happens, but as you're making a game chances are you have a function that gets called each frame. If so, you might want to do something like:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by user69728 great, that looks manageable. I'll continue with the project mid-november once all the components are there; meanwhile I can practice :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-28 by DrAzzy I'd do it the other way - set the pins input_pullup, and wait for them to go low, rather than high, and connect the other side of the button to ground instead of 3v3. Better practice to do it like this since you don't have to run the power rail all over hell (and you're already running ground all over hell), and a short involving Vcc is likely to be worse than a short involving Gnd. You'll find that this is almost always how non-matrix'ed buttons are done in commercial products. Also more generally applicable, since many micros only have pullups built-in, no pulldowns. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-31 by @gfwilliams As @drazzy says, that's probably more sensible. It just means that |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-10-27 by user69728
for a LED tetris game, I'll need a controller. Which joystick would you recommend and how do I connect/control it?
thank you,
Markus
Beta Was this translation helpful? Give feedback.
All reactions