Our library lets you control your servos in HITIPanel with sub-degree resolution, while the standard library only permits degree resolution. This feature allows for finer positioning (the position resolution of a servo is around 0.1°). It also allows to get smoother motions at low speed when using the servo motion control library.

In this example, you will see how to use the DIGITAL I/O Control Panel to control a servo on pin 8 with sub-degree resolution.


1 ) Wiring diagram

Connect a servo on pin 8 and add an electrolytic capacitor in parallel with the servo power supply (beware of the polarity!!!). Connect it as close as possible to the servo.


2) Sketch: 1_Basics \ 4_Servo

HITIComm internally creates and manages Servo variables from the standard Servo library. So, you don’t need to create any Servo variable.

We attach a Servo variable to pin 8 by using HC_attachServo(pin, position). We also use this function to move the servo to an initial position of 53.7°. The value must be given in millidegrees (53700 m°).

#include <HITIComm.h>

// pins assignment
const int pin_Servo = 8;

// run once at power on
void setup()
    // initialize library

    // attach servo to the pin. Initial position is 53.7°. 
    // (if not specified in parameters, default initial position is 90°)
    HC_attachServo(pin_Servo, 53700);

// run repeatedly after setup()
void loop()
    // communicate with HITIPanel


3) Control Panels

  1. Display the DIGITAL I/O Control Panel (“IO” button).
  2. The servo is at its initial position (53.7°). As you can see, the displayed value is not exactly the one we asked for. This is due to the positioning resolution of a servo which is around 0.1° but not exactly 0.1°.

  3. Change the value to move the servo to a new position. Try for instance 125.4°.


Was this article helpful?
0 out of 0 found this helpful