1

So I'm totally new to any electrical / circuitry related things, but there is one project I'd like to try with my Raspberry Pi 3. Basically I've got an external PCB that has different analog IO such as a joystick, buttons, etc. I was wondering if it was possible to use the GPIO pins on the pi to directly activate the buttons, and simulate the joystick input.

Basically I'm thinking of removing said buttons / joystick etc and soldering leads to the IO the button(s), etc were initially connected to. Then piping commands through the GPIO. (Essentially automating the button press / joystick moving)

That said, I guess this isn't a common use case as I can't seem to find anything online about this and everything instead is to connect a joystick to the pi instead of the other way around.

I come from a software background so programming side of things for the GPIO should be fine, the hardware side though, I'm not sure where to start.

1 Answer 1

1

It should be possible to control the buttons with the Pi GPIO however it might be a little harder to control the joysticks.

To control the buttons, you'll first have to check what voltage do the buttons give to be perceived as a logic HIGH and a logic LOW. You can check this with a multimeter and figure out whether pressing the button sends HIGH (3.3v or 5v) or LOW(0V). When you have this information, you can remove the buttons and make a connections from the side that sends the signal out from the button to a GPIO pin on the Pi and use that to generate the same signal.

Most of the Joysticks have an potentiometer connected to each axis and a button for press. Some of them combine the button press with the analog values going out to reduce the number of wires, so this would really depend on the joystick that you are using (It would be great if you could post the hardware that you are using). The joysticks usually works so that each axis would have a potentiometer which would generate an voltage depending on where the joystick is which would be converted by an ADC and sent to a micro-controller for processing. For example, it could be 0V for extreme left, 2.5V for center and 5V for extreme right. The values will keep increasing as you go for extreme left to right in this example. To simulate this, one you have found what the exact values for the joystick axis with a multimeter or an oscilloscope. Once you have that, you can try to generate it from the PWM pin on the Pi (the Pi only has 1 PWM pin so you would have a bottleneck here). It might be better to use a HAT like this which you can use to generate both the PWM signals to control the Joystick input and the the buttons.

3
  • Instead of PWM, I would suggest using and electronic potentiometer (or rheostat). Also, between the Pi GPIO pins and the joystick use a digital buffer, something like this maybe assets.nexperia.com/documents/data-sheet/74HC_HCT125.pdf. It will protect the pins from sourcing too much current (the pi is very limited, my advice from practice is to design to keep under 5mA), and it will allow the 3.3V from the pi to map to higher or lower voltages as needed.
    – A.S.
    Aug 22, 2018 at 6:23
  • The Pi has no analogue GPIO so can not directly read voltages. The Pi has two hardware PWM channels available on four accessible GPIO. It can also generate hardware timed PWM on any GPIO on the expansion header.
    – joan
    Aug 22, 2018 at 7:27
  • Thank's for the responses, these all give me a lot to work!
    – Hex Crown
    Aug 22, 2018 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.