Introduction: Wireless Gamecontroller With Arduino and NRF24L01+ (support for One or Two Controllers)
You can find the complete project from my website (it's in Finnish): https://teukka.webnode.com/l/langaton-ohjain-atmega-lla-ja-nrf24l01-radiomoduulilla/
This is a really short briefing about the project. I just wanted to share it if someone would like to build it and can't read Finnish.
Have you ever thought about playing web-based games with your friend, but the mapping is so bad that you have hard time playing it? Worry not, because you can build your own controller with custom mappings. I coded the controller to emulate a USB-keyboard, but you can use it as whatever you want.
Step 1: Parts
This is the hardware you will need:
- 2 pcs of Arduino Pro Mini (ATmega328P or something else will do)
- 2 pcs of NRF24L01+ modules for the wireless communication
- Arduino Leonardo or Arduino Pro Micro (receiver)
- 3D printed chassis (link below for the files)
- ISP programmer or USB -> RS232 converter to program the controllers
- 16 pcs of 20*20 mm buttons
- 2 pcs of Li-ion batteries for the controllers (REMEMBER PROTECTION CIRCUITS! You don't want to kill yourself! I recommend the TP4056-board which has USB-charing and protection in the same board!)
- 2 pcs of small slide switches (something like SS12D00G3)
- A lot of wires
- Dupont connectors (optional)
You can find the Fusion 360 model from here: https://a360.co/2QPYNe4
Step 2: Coding
Then just program the controllers (gamecontroller_dualcontroller.ino for the controllers if you want to use two controllers and gamecontroller.ino if you want to use only one) and the receiver (gamecontroller_dual_receiver_w_keystrokes.ino for two and gamecontroller_receiver_w_keystrokes for only one controller)
However you have to give the controllers different addresses. Just open the radioLink.ino and change the line 22 for the first controller to this:
radio.openWritingPipe(address[0]);
And for the second controller to this:
radio.openWritingPipe(address[1]);
If you want to change the mapping, change the mapping[8] array (or mapping2[8] for the second controller).
You can find the codes from my GitHub: https://github.com/Teneppa/gamecontroller
Step 3: Assembly
How to assembly the controller:
- Add necessary connectors to the charging circuit (and the switch to shut it down)
- Glue the charging circuit to the bottom part
- Add the switch and glue it in place
- solder the NRF24L01+ to the Arduino (CE to pin 7 and CSN to pin 8)
- Connect the buttons (another pin to ground and another to corresponding I/O pin, you don't really need the capacitors)
- Close the enclosure
How to assembly the receiver:
- Connect the NRF24L01+ to the Arduino
- You're done