Python Forum
GPIO pins to RaspPi - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: GPIO pins to RaspPi (/thread-35376.html)



GPIO pins to RaspPi - mmagner2022 - Oct-26-2021

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.


RE: GPIO pins to RaspPi - joe_momma - Oct-26-2021

(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.


RE: GPIO pins to RaspPi - mmagner2022 - Oct-26-2021

(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-Controller-JoyStick-Breakout-Arduino/dp/B00P7QBGD2/ref=sr_1_2?crid=1EGX9IONY3SH7&dchild=1&keywords=analog+joystick+for+raspberry+pi&qid=1635280726&sprefix=analog+joystick+for+raspberry+pi%2Caps%2C57&sr=8-2


RE: GPIO pins to RaspPi - metulburr - Oct-26-2021

Are you running this program on a pi or just using the pi to attach the joystick?


RE: GPIO pins to RaspPi - joe_momma - Oct-27-2021

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