Pokemon Battle Bot Joystick Documentation

by keshmaster81 in Circuits > Arduino

277 Views, 1 Favorites, 0 Comments

Pokemon Battle Bot Joystick Documentation

IMG_3508.jpg

The primary scope of this project was to build a remotely controlled battlebot capable of being laser-cut and assembled at a small scale (8-10 robots). This portion of the instructable will cover the design of the joystick transmitter system, from design to assembly to code. There are 3 main portions for the design of the transmitter. This is the laser-cut chassis enclosure, the arduino circuit, and the code.

Supplies

Parts:

  1. 2 4-way Arcade Joysticks.
  2. These joysticks use microswitches that detect on/off positions corresponding to each movement of the joystick. (https://www.canadarobotix.com/products/924)
  3. 1 Nrf24L101 radio module(https://www.canadarobotix.com/products/2437)
  4. 1 Protoboard/perfboard (https://www.canadarobotix.com/products/1160)
  5. 1 8 position dipswitch (https://www.canadarobotix.com/products/1968)
  6. 1 Arduino Uno(https://www.canadarobotix.com/products/60)
  7. Breakaway Male headers
  8. 8 Medium female spade connectors
  9. Jumper wires
  10. heat shrink tubing
  11. mdf board

Tools:

  1. wire strippers
  2. soldering iron
  3. solder
  4. m3 bolts, washers, and nuts
  5. laser cutter
  6. bandsaw
  7. drill press
  8. 1in x 2in x 2 foot wooden stake
  9. cordless drill and bits
  10. wood screws of various lengths

Nrf24L101 Radio Communication

Screen Shot 2022-08-26 at 4.15.36 PM.png

The star component of this project is the nrf24L101 radio module. This part allows us to control the robots wirelessly from our joystick box. For a detailed setup and explanation of these modules, check out the tutorial from HowtoMechatronics.

https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/

For more valuable resources on the nrf24L101 module setup, check out these links:

https://forum.arduino.cc/t/simple-nrf24l01-2-4ghz-transceiver-demo/405123

https://randomnerdtutorials.com/nrf24l01-2-4ghz-rf-transceiver-module-with-arduino/

https://lastminuteengineers.com/nrf24l01-arduino-wireless-communication/

Circuit Wiring Diagram

IMG_0011.jpg

This circuit diagram illustrates all the wiring connections between the arduino, radio module, dip switch and arcade joysticks.

As you can tell with the before and after pictures, the initial circuit was a mess until everything was soldered.

More Circuit Photos

IMG_3367.JPG
67986866326__6468F469-D6D7-43AC-9CFB-0046763D8126 3.JPG
IMG_3554.jpg

Designing and Laser Cutting the Enclosure

Screen Shot 2022-07-22 at 12.14.52 AM.png
Screen Shot 2022-08-21 at 7.28.36 PM.png
Screen Shot 2022-08-21 at 7.28.15 PM.png
IMG_3319.JPG
IMG_3365.JPG

The chassis was designed in the Onshape CAD software. Some important design considerations were the strength and rigidity of the boxes. The joystick boxes would be rigorously handled by kids and adults throughout the event, so it had to be strong to withstand any abuse and general wear-and-tear. This is why we opted for a design utilizing wood screws and wood support squares rather than relying on friction fit laser cut parts and geometry.

The initial prototype of the box was constructed out of cardboard, and was used to get an idea of the measurements and sizing of the box.

After finalizing the design, all faces of the box were exported as DXF files and cut on the laser cutter using the LaserCut5.3 software. The parts were cut out of 3mm hardboard/mdf.

Assembly of the Enclosure

IMG_3553.jpg
IMG_3550.PNG

To assemble the arcade joysticks to the top plate of the box, I used m3 bolts, nuts and washers.

To assemble the box itself, I aligned the wood support squares with the faces, marked and pre drilled holes, then screwed the support squares to the side plates. The plate holes were designed in a manner so that every screw hole was offset so the screws would never touch when drilling into the box.

After mounting the support squares to the side plates, I proceeded to mount the side plates(with the support squares attached, to the bottom plate, followed by the back plate and the top plate. Screws of various lengths were used to ensure none were sticking out of the support squares.

The next part of the installation involved mounting the perfboard housing the dip switch and nrf24L101 radio module to the front plate through the appropriate cutouts. The perfboard mounting holes were marked through the mdf, holes and drilled, and finally mounted with m2 screws and bolts.

A hole and cutout was created in the front plate for uploading code and attaching a power supply to the arduino's barrel connector. These additions will be added to the latest version of the CAD files. The arduino itself was mounted to the base plate with velcro, and the wires were internally zip tied to keep things nice and neat.

Lastly the front plate was screwed onto the rest of the box.

This completes the assembly of the enclosure.

Programming

To access the up-to-date files for the transmitter and receiver, check out the github files at the link below:

https://github.com/carobot/NIU-Sumo-Robot


You can get an idea of the project with the proof of concept code pasted below:


#include <SPI.h>.

#include <RF24.h>

#include <nRF24L01.h>


int axisdata[8]; //creates the array in which the joystick data is sent.


int upSwitchA = A5; // defining the joystick pins below

int downSwitchA = A3; 

int leftSwitchA = A2;

int rightSwitchA = A4;


int upSwitchB = 2;

int downSwitchB = 3;

int leftSwitchB = 4;

int rightSwitchB = 5;


RF24 radio(9, 10); // define the CE and CSN pins for the radio module


const byte address[6] = "00001"; //set the address in which both transmitter and receiver communicate


void setup() {

 // put your setup code here, to run once:


 Serial.begin(9600); //try 115200

 radio.begin();

 radio.openWritingPipe(address);

 radio.setPALevel(RF24_PA_MIN);

 radio.stopListening();

 

 radio.setChannel(76); //sets the rf frequency channel that the radio module will transmit on.


pinMode(upSwitchA, INPUT_PULLUP); //initializing the switch pins for the joystick

 pinMode(downSwitchA , INPUT_PULLUP);

 pinMode(leftSwitchA, INPUT_PULLUP);

 pinMode(rightSwitchA, INPUT_PULLUP);


 pinMode(upSwitchB, INPUT_PULLUP);

 pinMode(downSwitchB, INPUT_PULLUP);

 pinMode(leftSwitchB, INPUT_PULLUP);

 pinMode(rightSwitchB, INPUT_PULLUP);

}


void loop() {

 // put your main code here, to run repeatedly:


int upValA= digitalRead(upSwitchA); //reading the HIGH/LOW value at each switch

int downValA = digitalRead(downSwitchA);

int leftValA = digitalRead(leftSwitchA);

int rightValA = digitalRead(rightSwitchA);


int upValB= digitalRead(upSwitchB);

int downValB = digitalRead(downSwitchB);

int leftValB = digitalRead(leftSwitchB);

int rightValB = digitalRead(rightSwitchB);


axisdata[0] = upValA; //assigning each switch value to an element in the array

axisdata[1] = downValA;

axisdata[2] = leftValA;

axisdata[3] = rightValA;


axisdata[4] = upValB;

axisdata[5] = downValB;

axisdata[6] = leftValB;

axisdata[7] = rightValB;


radio.write(&axisdata, sizeof(axisdata)); //sending the entire array containing switch positions to the receiver


}