Python Forum

Full Version: GPIO pins to RaspPi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am currently trying to program a simple pong game using pygame and thus far I have used pygame.KEYUP and pygame.KEYDOWN to control the game. I have a joystick that connects to the raspberry pi with GPIO pins and I am not sure how to program the game to use the joystick instead of the keyup and keydown controls. I cannot for the life of me figure out the imput commands to get the gpio pins to work with the joystick. Any help would be greatly appreciated.
(Oct-26-2021, 05:30 PM)mmagner2022 Wrote: [ -> ]I have a joystick that connects to the raspberry pi with GPIO pins
what does that mean?
the easiest way is to use a play station controller connected by usb and pygame joystick.
joystick info
post your coding attempt/ wiring diagram/ components used.
(Oct-26-2021, 07:44 PM)joe_momma Wrote: [ -> ]
(Oct-26-2021, 05:30 PM)mmagner2022 Wrote: [ -> ]I have a joystick that connects to the raspberry pi with GPIO pins
what does that mean?
the easiest way is to use a play station controller connected by usb and pygame joystick.
joystick info
post your coding attempt/ wiring diagram/ components used.

So thats the problem, I understand the concept of the pygame.joystick page but the joystick that I am attaching doesn't use a usb connection, but rather connects with GPIO pins. Here is an amazon link of what the product is: https://www.amazon.com/HiLetgo-Controlle...C57&sr=8-2
Are you running this program on a pi or just using the pi to attach the joystick?
Quote:joystick potentiometer with (X, Y) 2 axis analog output, (Z) 1 button digital output.
looks like it's an analog output so you'll need an A/D converter
check out this tutorial:
joystick