2 years ago.

Movement of Servos with Threads!

Good, I'm doing a hexapod that has 18 servos and 6 legs (3 servos for each leg) and in which I have declared the pins of each servo in a Multi-dimensional Arrays. In addition, I have a function that generates the movement of the servo depending on the degrees that it passes and a main that tests a servo in specific. My question is: I have a function called "mover_pata1" in which I pass a character as an argument and I create a switch in which depending on the selected character makes one movement or another the hexapod, but I would like all the movements of the servos were at the same time and I've been looking and I do not know if it could be with threads, create 1 thread for each leg (a total of 6 threads), tasks or I do not know. What can I use to make my code efficient and how would it be with a small example?

I attach my code:

Thank you !!

Be the first to answer this question.