Raspberry PI, XBox 360 controller, and Relay success!

Опубликовано: 26 Март 2026
на канале: Eve Shadow
761
6

Youtube broke my formatting - so here is a pastebin of the below comment so that you can view it with the correct indentation;
http://pastebin.com/uY2P6RsB

I just had a happy moment because this worked.

For those interested, here are the basic steps taken.
Hopefully you find them moderately helpful;


In the console;
sudo apt-get install xboxdrv
sudo xboxdrv --detach-kernel-driver
git clone https://github.com/FRC4564/Xbox.git


Then, in a python file (eg, example.py):
import xbox
import RPi.GPIO as r
from time import sleep
channels = [21, 20, 16, 12] # Change these to whatever GPIO ports you want to use
joy = xbox.Joystick()

try:
r.setmode(r.BCM)
for c in channels:
r.setup(c, r.OUT)

This is just for testing, the whole forloop can be safely removed
for c in channels:
r.output(c, False)
sleep(0.1)
r.output(c, True)
sleep(0.1)

while not joy.connected():
sleep(0.1)

while joy.connected():
r.output(channels[0], joy.A())
r.output(channels[1], joy.B())
r.output(channels[2], joy.X())
r.output(channels[3], joy.Y())

finally:
r.cleanup()
joy.close()


Then simply run it! (Sudo required for GPIO port access)
sudo python example.py