Two years on after I started learning about robotics and electronic engineering. I decided to revisit a problem that I couldn't find a solution for when building Zebra (Ada's first robot). I wanted to use my old Xbox 360 controllers and their wireless receiver to operate robots directly.
It sounds like a relatively simple problem, however the XBOX360 wireless receiver is very picky about the host controller it's plugged into, and the host controller can also be very picky about the device that it's plugged into. After weeks of failing to get this to work, I packed the XBOX360 controllers away.
It's 2020 and everything is an IoT MQTT device - even your 15 year old XBOX360 controllers. I still had the original Ardiuno Uno and a USB host shield from Keyestudio that I had purchased to build Zebra. The Uno and the USB shield had always been a stable combination when using the XBOX360 wireless controller - however at the time I lacked the knowledge to turn this into a working robot controller.
The simplest solution was to connect the Arduino Uno to the ESP32 via the arduinos serial pins and to the second serial (UART) on the ESP32. The ESP32 is much easier to use in this respect as it has multiple UARTs compared to the ESP8266.
The ESP8266, it claims to have to two UARTs howevers both of them are basically in use - one for programming and the other for the flash memory access.
The ESP32 and the Arduino have differant logic levels (5v & 3.3v), the hardware incorporates a logic level shifter for both the transmit and recieve lines.
I added a small SSD1306 OLED display to show some stats and the XBOX360 logo. To house the project I used circular USB panel mount sockets for the first time, these are much easier to install as it just requires a hole drilled and not my usual butchery with a dremmel.
Serial Command | Serial Value | MQTT Topic | MQTT Value |
---|---|---|---|
STOP | |||
START | |||
XRC: | True | ||
XCC: | 1 | ||
Battery: | 0-3 | XBOX360/Battery | 0/3 |
L2: | 0-255 | XBOX360/Trigger/Left | 0/100 |
R2: | 0-255 | XBOX360/Trigger/Right | 0/100 |
LHX: | -32768/32767 | XBOX360/Stick/Left/X | -100/100 |
LHY: | -32768/32767 | XBOX360/Stick/Left/Y | -100/100 |
L3: | C | XBOX360/Stick/Left | Click |
RHX: | -32768/32767 | XBOX360/Stick/Right/X | -100/100 |
RHY: | -32768/32767 | XBOX360/Stick/Right/Y | -100/100 |
R3: | C | XBOX360/Stick/Right | Click |
U: | C | XBOX360/D-Pad/Up | Click |
U: | P | XBOX360/D-Pad/Up | Press |
D: | C | XBOX360/D-Pad/Down | Click |
D: | P | XBOX360/D-Pad/Down | Press |
L: | C | XBOX360/D-Pad/Left | Click |
L: | p | XBOX360/D-Pad/Left | Press |
R: | C | XBOX360/D-Pad/Right | Click |
R: | P | XBOX360/D-Pad/Right | Press |
START: | C | XBOX360/Button/Start | Click |
BACK: | C | XBOX360/Button/Back | Click |
XBOX: | C | XBOX360/Button/XBOX | Click |
SYNC: | C | XBOX360/Button/SYNC | Click |
A: | C | XBOX360/Button/A | Click |
B: | C | XBOX360/Button/B | Click |
X: | C | XBOX360/Button/X | Click |
Y: | C | XBOX360/Button/Y | Click |
A: | P | XBOX360/Button/A | Press |
B: | P | XBOX360/Button/B | Press |
X: | P | XBOX360/Button/X | Press |
Y: | P | XBOX360/Button/Y | Press |
L1: | C | XBOX360/Bumper/Left | Click |
L1: | P | XBOX360/Bumper/Left | Press |
R1: | C | XBOX360/Bumper/Right | Click |
R1: | P | XBOX360/Bumper/Right | Press |
MQTT Topic | MQTT Value | Serial Command | Serial Value |
---|---|---|---|
setBigRumbleOn: | 0-3 | XBOX360/1/Battery | 0/3 |
setBigRumbleOn: 0-255 setSmallRumbleOn: 0-255 setBothRumbleOn: 0-255 setRumbleOff setLedOn: 1 setLedOn: 2 setLedOn: 3 setLedOn: 4 setLedMode: All setLedMode: Alternating setLedMode: Rotating setLedMode: FastBlink setLedMode: SlowBlink setLedMode: Off setLedOff