Using the servomotor controller
After we have assembled the servomotor controller circuit, we need to work on the Arduino sketch of the servomotor controller.
However, before that, you need to know that we need to match the turn of our potentiometer to the change on the angle of the servomotor. We should be wary of the potentiometer and be extra careful of our precision. We want our servomotor to give a relevant change with the turn that we make on our potentiometer.
Since we are using the Galileo board Gen 2, this wouldn't be a problem. Thanks to its 12-bit PWM output, we can be ensured of precision control.
Galileo Gen 2 makes use of an NXP PCA9685 PWM driver IC with 12-bit resolution. This is what makes a fine-grained control on the PWM duty cycle possible.
At this time, we are ready to write the code which will enable us to control the servomotor through the potentiometer, by following these steps:
- The first thing that we should do is include the servo library, so that we will have...