Download and Run the Code

Download the Code Install Libraries

We can download the files by using git clone in the command line.

cd /home/pi/
git clone
cd pan-tilt-hat
sudo python3


Running will download some necessary components. You may fail to download due to network problems. You may need to download again at this time.


Run the in the examples/ folder.

cd /home/pi/pan-tilt-hat/examples
sudo python3

To make sure you can see that the servo has been set to 0°, you can insert a rocker arm in the servo shaft first and then turn the servo to another angle.


Now follow the diagram below and insert the servo to the P0/P1 position.


Now if the servo arm shifts and stops at a specific position, the function will take effect. If it is not, please check the insertion direction of the servo cable and re-run the code.