top of page
  • Jennifervandenbrand

Connecting multiple servos | Part 1

Updated: Mar 9, 2021

For my final product, I will likely be using more than 2 servos. Since the previously tested eye prototype has 2 working servos, I expect that there will be no problem connecting more. In the documentation about this tool, Dan Thompson writes that it is possible to connect up to 4 servos, but there are options to extend this even further.


Connecting the fourth servo


The third servo worked like a charm, but sadly, the fourth did not respond. I checked the wires, and to be sure, I swapped out the device with another, but that didn't fix the problem. As a last resort, I dove into the scripts, and there I found the problem.


In the servo.py script, a variable called "lastAngle" is initialized with an array of 3 integers. This variable stores the last position of the servos. The problem with this value is that it only has 3 spots, one for each servo. Since we are trying to connect the fourth servo, we need to create a spot for its data to be stored.


Adjusting the script


To accommodate the fourth servo, we need to add one extra spot in the array.

Figure 1. Screenshot STFM-script with an array of 3 integers (Own work)

Figure 2. Screenshot of STFM-script with an array of 4 integers (Own work)


Theoretically, we can already save a few extra spots in this variable for when we want to connect more than four servos in the future. However, these extra servos won't immediately work since the Arduino script is hard-coded to accommodate only four servos. The missing spot in the lastAngle variable is, therefore, an error. When we want to connect more than four servos, the Arduino script also needs adjustment.




21 views0 comments

Comments


bottom of page