Pan_Tilt lib for C/C++


I am searching for how to access C/C++ libraries for the Pimoroni Pan-Tilt HAT. I have found the python libs but I do not think that that is enough to use the HAT from C/C++.
If the C/C++ lib is not available, is there documentation on the I2C commands that need to be sent to the HAT to gain control of the servos?


Presently there is no documentation on the i2c interface, since the firmware that drives Pan Tilt HAT is completely custom, however briefly:

0x00 = Config
0x01 = Servo 1 (two bytes, most significant first)
0x03 = Servo 2 (ditto)
0x05 = ws2812 pixel data, this goes from register 0x05 to 0x4c
0x4d = update register, trigger an update for the ws2812 pixels

The 2 byte unsigned integers for Servo 1 and Servo 2 represent the time, in microseconds, of the servo high pulse. A pulse is typically something like 500 to 2500 (0.5ms to 2.5ms) microseconds which is repeated every 20 milliseconds.

The config register is as follows, from LSB to MSB:

0 - Enable Servo 1
1 - Enable Servo 2
2 - Enable lights
3 - Light mode - 1 = ws2812, 0 = regular on/off toggle
4 - Light polarity - 1 = active low, 0 = active high

The ws2812 pixel data is 72 bytes long- it doesn’t care if you send 18 sets of RGBW data or 24 sets of RGB data. It also doesn’t care what order the pixels are sent in, but will forward the data you give it directly on to the attached ws2812 or sk6812 pixels. So, use the pixel order and format suitable for whatever you have connected.

Hopefully that should get you started! I should probably codify this in a brief datasheet.


Thank you very much for the info.
I also purchased an Automation HAT. Is there any way that you could provide information on that piece of hardware?


All the information on which pin connects to what is here:

The Automation HAT then has an ADS1015 ADC on board, plus an SN3218 LED driver.

The former is documented here: and should have a whole bunch of C-like embedded example code floating around on the internet that you could draw on for inspiration.

The SN3218 is documented here:

Our own Arduino library might help you better understand how it works (it’s really, really simple as far as i2c devices go anyway)-