This project shows how control the GoPiGo with a PS3 Dualshock 3 controller.
The PS3 controller can be used to control the GoPiGO with a bluetooth adapter. You have to pair the PS3 with the GoPiGo first and you’ll have your own cool RC car.
You can try out his example to see how to control the GoPiGo with a PS3 adapter and adapt it into projects of your own.
- A fully assembled GoPiGo
- Wifi Adapter for connecting and controlling the GoPiGo
- A bluetooth adapter for connecting the PS3 controller
- A PS3 Dualshock 3 controller
Connecting the Bluetooth Adapter and the PS3 controller:
- Connect the Bluetooth adapter to any of the USB ports.
- Connect the PS3 controller to the Raspberry Pi with a USB Mini A/B cable.
Setting up the GoPiGo
Make sure that the GoPiGo is set up properly and you have the updated software and firmware. If you are not sure about this, follow the guide here.
If the GoPiGo is properly set up, connect to the GoPiGo via SSH or VNC and open terminal.
Running the example:
- Go to the PS3 Control folder:
- Next, connect your PS3 Controller to the Raspberry Pi, using the USB cable. In the command line, make the program “sixpair” executable and run it. This will pair the PS3 controller to the Bluetooth adapter.
sudo chmod +x sixpair sudo ./sixpair
- Disconnect the USB cable which was connected to the PS3 controller. Press the PS button on the PS3 controller (this is the round button in the middle, between the “Select” and “Start” button on the controller) and a couple of random buttons on the controller. The light on the Bluetooth adapter should become solid green from the blinking green earlier.
- Start the bluetooth pairing method:
- Now, still in the
bluetoothprogram, start to press buttons. You should see something like this:
[bluetooth]# agent on Agent registered [NEW] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95 [CHG] Device 64:D4:BD:3A:E1:95 Connected: no [DEL] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95 [NEW] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95 [CHG] Device 64:D4:BD:3A:E1:95 Connected: no [DEL] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95 [NEW] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95 [CHG] Device 64:D4:BD:3A:E1:95 Connected: no [DEL] Device 64:D4:BD:3A:E1:95 64-D4-BD-3A-E1-95
- Note down the mac address of the device. In our case, it’s
- Run the “connect” command, followed by the bluetooth mac address of your device. In our case, this will be
- Finally, set the device as trusted. We’ll use the “trust” command: `trust 64:D4:BD:3A:E1:95`
quitto exit the bluetooth pairing program.
- Finally type
sudo rebootto reboot the computer.
- Check that the PS3 controller has paired. Press the PS button in the center of the controller again and type
ls /dev/input/js*You should see something like
Note: if you received
ls: cannot access /dev/input/js*: No such file or directory try pairing your controller again by pressing the PS button.
Start the PS3controller example :
After pairing your PS3 controller with the Pi, we’re ready to run our code.
sudo python ps3_gpg_example.py
To control the GoPiGo from the Ps3 controller:
- Use the Up,Down,Left,Right buttons to control the motion of the GoPiGo.
- Use L2 to increse the speed.
- Use R2 to decrease the speed.
- Use the left joystick to control the servo position.
You can easily adapt this example to any project which can make use of a PS3 controller with the GoPiGo.
Have a question? Go check out our support page here or post it on the forums here.