Hexapod project

Hey there, I've started to build an hexapod for a school project, the structure is almost completed and I was wondering how I would go about the programming. The materials I'm gonna be using are a 7.4V 4000mAh lipo hooked up to a 5V regulator, 18 servos, an arduino mega and an esp32 for WiFi control over the phone using an app called Blynk.

My current understanding of how this will all work together isn't the greatest, so I thought it would be better to have some opinions and suggestions on how to bring it to life.

At first I only wanted to use the ESP32, but I found out that it doesn't have enough PWM pins so I tried to use an MCP23017 to expand the ammount of controllable pins but after hours of trying I gave up on it and decided to use a mega with serial communication to go around the lack of pins issue. For now my plan for the program would be to receive the input from Blynk through the ESP32, send an integer depending on what the desired action is (for example, send 1 to walk forwards, send 2 to walk backwards) and have some functions on the mega to perform it. I also wanted to try and send the battery percentage to the app, but after a quick search it seems that it's hard to calculate it precisely, ignoring the problem of the controllers being connected to the same battery as every component.

I've looked into inverse kinematics and the concept is great but I can't wrap myself around how I could make such a program.

The battery works with all these components on it, due to deadlines I can't wait for a servo expansion board which I already bought so my options are limited.

Your most serious problem will be motor power.

If your servos are typical, and all 18 are moving at once, the power draw could be as high as 18 Amperes (momentarily around 100 Watts). Less for microservos, but still quite impressive.

Hopefully you will have taken this into account in your selection of voltage regulator and battery. If not, you may be down to moving just one motor at a time.

Best of luck with those pesky deadlines!

I have stress tested it and I could get about 14 servos moving at once without a problem, with the arduino mega also being connected to the same battery.

Thank you for the luck, I'll need every last bit!