# Getting pan/tilt to work with servo pHat and RPi cam interface / Sphero RVR

**URL:** <https://community.sparkfun.com/t/getting-pan-tilt-to-work-with-servo-phat-and-rpi-cam-interface-sphero-rvr/39188>\
**Category:** Kits\
**Created:** [March 21, 2020, 3:48pm UTC](https://community.sparkfun.com/t/getting-pan-tilt-to-work-with-servo-phat-and-rpi-cam-interface-sphero-rvr/39188 "2020-03-21T15:48:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpvillamil](https://avatars.discourse-cdn.com/v4/letter/g/82dd89/32.png) [@gpvillamil](https://community.sparkfun.com/u/gpvillamil)\
**Post date:** [March 21, 2020, 3:48pm UTC](https://community.sparkfun.com/t/getting-pan-tilt-to-work-with-servo-phat-and-rpi-cam-interface-sphero-rvr/39188/1 "2020-03-21T15:48:39Z")

</div>

Hi there!

I’ve just configured a Raspberry Pi 3 to work with the Sphero RVR, and I’m installing all the various bits and pieces from scratch. I can’t get the controls in the Pi webcam interface for pan and tilt to show up.

I’ve installed the Sparkfun code from here:

[https://github.com/sparkfun/sparkfun\_autonomous\_kit](https://github.com/sparkfun/sparkfun_autonomous_kit)

[https://github.com/sparkfun/PiServoHat\_Py](https://github.com/sparkfun/PiServoHat_Py)

The webcam interface from here:

[https://github.com/silvanmelchior/RPi\_Cam\_Web\_Interface](https://github.com/silvanmelchior/RPi_Cam_Web_Interface)

And Sphero SDK from here:

[https://github.com/sphero-inc/sphero-sd … ypi-python](https://github.com/sphero-inc/sphero-sdk-raspberrypi-python)

I moved piservohat\_web\_interface\_firmware.py into the RPi\_Cam\_Web\_interface folder

All the hardware tests work. I can move the pan and tilt servos using the servo pre-alignment and hardware test examples.

When I start the RPi\_Cam\_Web\_interface, I do get the video stream.

However, the little control arrows for pan and tilt don’t appear.

Is there anything I am missing?

---

<div class="post-metadata">

**Author:** ![gpvillamil](https://avatars.discourse-cdn.com/v4/letter/g/82dd89/32.png) [@gpvillamil](https://community.sparkfun.com/u/gpvillamil)\
**Post date:** [March 23, 2020, 2:32pm UTC](https://community.sparkfun.com/t/getting-pan-tilt-to-work-with-servo-phat-and-rpi-cam-interface-sphero-rvr/39188/2 "2020-03-23T14:32:31Z")

</div>

Ok I sorted this out, following a combination of instructions from here:

[https://learn.sparkfun.com/tutorials/se … l#new-page](https://learn.sparkfun.com/tutorials/setting-up-the-pi-zero-wireless-pan-tilt-camera/all#new-page)

and here:

[https://elinux.org/RPi-Cam-Web-Interfac … r\_Pi-Light](https://elinux.org/RPi-Cam-Web-Interface#Pan-Tilt_or_Pi-Light)

Setting it up the same way as the Advanced Autonomous Kit for Sphero RVR has some changes.

The first few steps are much like the Pan-Tilt camera instructions, first install the package:

```auto
git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
./install.sh

```

This is different!

Copy piservohat\_web\_interface\_firmware.py into the RPi\_Cam\_Web\_Interface directory

Signal to the software that you want to enable pan/tilt - you do this by renaming ‘pipan\_off’ to ‘pipan\_on’, the software looks for that file as the signal that it should show the pan/tilt controls.

```auto
sudo mv /var/www/html/pipan_off /var/www/html/pipan_on

```

Set up a “pipe” between the RPi cam interface and the software that will move the motors:

```auto
sudo mknod /var/www/html/FIFO_pipan p
sudo chmod 666 /var/www/html/FIFO_pipan

```

Different!

Open and edit the startup script

```auto
sudo nano start.sh

```

Add this line to the end of the script, this starts the motor control software when the cam interface starts

```auto
python3 piservohat_web_interface_firmware.py &

```

Open edit the shutdown script

```auto
sudo nano stop.sh

```

And add these two lines to the end of the script, this shuts down motor control when you stop the cam interface

```auto
kill $(pgrep -f 'piservohat_web_interface_firmware.py')
pkill -f piservohat_web_interface_firmware.py

```
