DIY Strategy and Card Game Using ESP32, MG996R, PCA9685 | Www.fiendsandlight.com

by fiendsandlight in Circuits > Arduino

495 Views, 0 Favorites, 0 Comments

DIY Strategy and Card Game Using ESP32, MG996R, PCA9685 | Www.fiendsandlight.com

20230522_214533.jpg

Fiends and Light is a DIY Strategy and Card Game created from 3D printing and hobby electronics.

There are basically 2 boards as shown, with one PS4 controller controlling 4 of the servo platforms on one board each.

Between the 2 boards is a Bridge.

The rest of this Instructable is to flesh out the 3D printed parts, the circuit within, and how to assemble everything together.

For more information on the rules of the game, please visit Fiends and Light website here.

Supplies

Hobby 3D Printer (eg. Ender 3 v2)

Filaments - PLA+

ESP32

PCA9685

4x MG996R

2 Original PS4 Controllers

1x 3AA Battery Box

1x 4AA Battery Box

Wires

M3 Screws (3mm x 12mm)

3D Print the Parts

A standard hobby printer with stock parts (ie Ender 3 V2) can print out the parts mentioned below.


Slicer Settings - Cura Slicer

PLA+, ESUN Filament


If you are new to 3D printing, I suggest that you go through YouTube video tutorials (tons of it on how to 3D print and troubleshoot) or attend a 3D printing course in your home area.


For the source STL files, get it here at Fiends and Light.


This is the entirety of 1 board. At least 2 boards are needed to play the game.


This is the base of the board, where you house all the DIY electronics (the parts are mentioned in later blog posts on how to set up the circuit and installation of the code), including the servo motors which are the highlight of this game.


This is the top cover of the board, where it rests on all the servo motors. Take note that it is meant to be taken out easily so one can access the batteries of the circuit to replace them as and when needed.


This is the side cover of the board, to be linked together with the corners of the board. There are 2 of these covers in 1 board, to cover both sides of the board.


This is the corner of the board, and there are 4 of them. They are meant to be glued to the board so as to give the fragile board some sort of structure to work with.


This is one set of servo holder. The servo is meant to be housed in the bigger piece and the smaller piece is to affix the servo onto the holder. There are 4 sets of these holders in one board.


This is the servo platform to be placed right on top of the servo. This piece is where all the marbles will go through during the gameplay, which are mentioned in later blog posts.


Lastly, this is the bridge that connects the 2 boards together, and is the part where the main point of contention (gameplay) between the boards will happen.

Setting Up the Electronics

The electronics system requires the following components:

ESP32 x 1

PCA9685 x 1

MG996R 360 degrees servo motors x 4

PS4 Controller original version x 1

Power sources (2 batteries boxes) - 1x 3AA and 1x 4AA both boxes with red and black wires


For source files, get it here at Fiends and Light.


The ESP32 is used as a motherboard to upload the Arduino code into and to serve as the MAC address to connect with the PS4 controller. The PS4 controller is used to give directions to the 4 servo motors to either move clockwise or anti clockwise. The servo motors are connected to a PCA9685 which acts as a channel between the ESP32 and the motors.


Wires would have to be connected from the servo motors to the PCA9685 which are then connected via wires to the ESP32. The PS4 controller is connected to the ESP32 via Bluetooth. Lastly, one power source is connected to the ESP32 and one power source to the PCA9685 to give the servo motors power to move.


First, let's upload the pairing PS4 controller code into the ESP32. Connect the ESP32 to the computer via a micro USB cable.



Open the file "GetBluetoothMacAddress.ino" from the files you downloaded under the section "Licenses and Products" of this website.

Then, go to your computer drive and search for "Device Manager".

You would be able to see the COM port of the ESP32 as shown here.

Go back to the ino file and select the correct COM port.


Then upload the ino file into the ESP32 as shown. Remember to press and hold onto the BOOT button on the ESP32 when uploading.



The Arduino IDE will show that the upload is completed.

Then open the Serial Monitor as shown. Press the RESET button on the ESP32 and copy the MAC address.


Install the sixaxispairtoolsetup.exe from the Zip file you downloaded from "Licenses and Products" page of this website.

Next, plug the PS4 controller to the computer and open the SixAxisPairTool application.

Copy and paste the MAC address to the field and press update.


The PS4 controller is now paired with the ESP32.

Now we have to upload the code of moving the servo motors to the ESP32.

Open the file "PS4ControlServoMotor.ino" from the Zip file you downloaded from "Licenses and Products" page of this website.


Hold the BOOT button while uploading the code into the ESP32. The programming is now done.

Now it is time to integrate all the components together.

The following diagram shows the circuit layout.


When connecting the servo motors, place the wires into the channel 0, 1, 2 and 3, in essence the left most pins on the PCA9685.


When connecting the PCA9685 to ESP32, it is as follows:

GND to GND

VIN to VCC

SDA to D21

SCL to D22


When connecting the 3AA power source to the ESP32, the red wire goes to VIN/VCC and the black wire to GND. The tricky part is to connect the power source wires to the same pins as from the wires of the ESP32 as shown.



Connect the 4AA power source to the PCA9685 as shown. Remember to unscrew the PCA9685 as shown first before inserting the red wire to the V+ and black wire to the GND and screwing it in to secure the wires.


Testing the system out -

Put in the batteries into the two power sources and on the PS4 controller. Test out how each button moves the servo motors differently.

Fitting the Parts Together

First, use super glue or plastic glue to affix the yellow corners onto the main white board.




Then use M3 screws (3mm) x 12mm to fix the Metal Horns onto the Servo Platforms. Fix 4 of them as shown on the 4 MG996R servo motors.








Next, use super glue to affix the servo holder pieces together as shown. Repeat for another 3 times.




Next, place the two power sources on opposite ends of the board, with the red pieces covering the two power sources. Place the ESP32 and PCA9685 in the middle as shown. You can choose to use bluetack or masking tape to fix the ESP32 and PCA9685 in place.




Place the servo motors onto the board as shown. Connect the servo motor wires to the PCA9685 channel pins.

Channel 0 - Top Left

Channel 1 - Top Right

Channel 2 - Bottom Right

Channel 3 - Bottom Left




Cover the whole electronics with the grey board as shown. Do not glue the grey board onto the servo holders as you would need to take it out in the future to replace the batteries for the power sources.



Weakness - Fragile and meant to be treated with care and not recklessly thrown around

Printing the Cards

Download the card design zip file from the store on this website.


A card will look like this:






There are 3 ways to print the cards.


The most cost effective way is to paste the jpeg files onto a ppt and print it out on glossy paper. Remember to print the back of the card too. Glue the card design and the back of the card together and then laminate it with a laminating machine.


One such example is found here - https://docs.google.com/presentation/d/1B2uE9b_QOkMGMnCF881grXBZiRTrTzLzKv59FrjK2MU/edit?usp=sharing


However, the resolution of the cards is low and blurry and it won't feel smooth playing it.


The second option is to engage an online game card printing service provider. One such example is www.makeplayingcards.com


If you just want to print a few sets for own personal usage with friends, this is the optimal solution. Just paste the jpeg files onto the website and you are good to go. I recommend to get at least 4 of every card design. This is cause it will add depth to the gameplay if you have more variety in the way you field your cards.


The last option is to engage a local professional card printing service provider. They come cheap, provided you buy in bulk from them, certainly at a lower cost than online services. This is suitable for people who want to monetise this game and to have many playable sets at any given point in time.



Playing the Game

Please visit the Fiends and Light website to know more about the rules of the game -