Adding a Joystick to the Raspberry Pi

by dexter_industries in Circuits > Raspberry Pi

17413 Views, 51 Favorites, 0 Comments

Adding a Joystick to the Raspberry Pi

front.JPG

Joysticks are really fun to use. They are also much more intuitive than other input devices. Adding a joystick to your Raspberry Pi opens a lot of new doors. You can now use the Raspberry Pi and the joystick to control a robot, a camera, play games or do whatever you want.

We'll be using the GrovePi and a Grove Joystick in this guide and show you how easy it is to integrate a joystick in your next Raspberry Pi Project

Hardware Required

parts.JPG

  1. A Raspberry Pi
  2. Grove Pi
  3. Grove Joystick
  4. Grove 4 pin cable

Connect the Joystick to the Raspberry Pi

connecting.JPG

First mount the GrovePi shield on the Raspberry Pi. Then take the Grove Joystick and connect it to the port A0 of the GrovePi. Now power on the Raspberry Pi

Setting Up the Software

setting_software.JPG

Clone the Grove Pi repository to the Desktop on your Raspberry Pi.

git clone https://github.com/DexterInd/GrovePi.git

Once you have downloaded the repository, go to the /Software/Python folder in the GrovePi folder.

cd GrovePi/Software/Python/


Getting the Data From the Joystick

joystick_data.JPG
using_joy.JPG

Just run the Python Program and you'll start getting the Joystick data back.

sudo python grove_thumb_joystick.py

Move the joystick and you'll see the data getting updated.

You can now use this Joystick to control your robot, RC airplane or whatever you want to control.