Moved to Raspberry Pi Projects
Control GPIO using any compatible bluetooth gamepad.
Make sure you have Node.js v16 (I used v16.17.0, I don't think earlier versions will work. Later versions will probably work) installed. Download Node.js.
Install dependencies (usually with npm i
)
Run the examples
Does not need a GPIO (I think it could work on any Linux device)
Has some LEDs and a button. The setup I did:
The examples need some environmental variables. You can copy the example.env
file to .env
and then customize (like if you use differnet GPIO pins).
node autoConnect.js
- Watches for gamepads being connected and disconnected
- Outputs events for every gamepad when you press a button or move an axis
- Interacts with GPIO
- Bluetooth light turns on when gamepad is connected
- Pressing button 0 (which is A on the Xbox controller I used) turns on the yellow output light
- Pressing the button will scan for bluetooth devices and automatically try to connect to any gamepad. Currently only recognizes
Xbox Wireless Controller
, but if there is another gamepad name you use you can add it and make a pull request. Because of this bug innode-ble
you will have to connect the controller fast. After around 20 seconds the code will crash.