Skip to content
Troll cats with a camera guided laser pointer which can be controlled through a web interface.
Python JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
cat laser diagram.xml


Livestream the video of a raspberry pi to a webserver (nodejs), which users can connect to, and control a pan-tilt combo of servos to control the rpi camera and laser pointer.

Also see my blogpost on this project.

The order is:



Requires ffmpeg, vl4-utils, nodejs, npm, pigpio, RPi.GPIO

  • git clone
  • cd TrollBot/video-streaming
  • npm init
  • npm install ws
  • cd ../webapp
  • npm init
  • npm install express

How to run

First connect all hardware as defined in the Hardware section.
Then startup the Raspberrypi and execute the following commands in the terminal:

  • Terminal tab 1:

    • cd video-streaming
    • node websocket-relay yoursecret 8081 8082
  • Terminal tab 2:

    • Setting for raspberry camera v2 module:
      • sudo modprobe bcm2835-v4l2
        • ffmpeg -s 640x480 -f video4linux2 -i /dev/video0 -f mpeg1video -b 800k -r 30 http://localhost:8081/yoursecret
      • ctrl - C
      • ffmpeg -i /dev/video0 -vf "vflip,hflip" -f mpegts -codec:v mpeg1video -bf 0 -s 640x480 -r 30 -b 800k http://localhost:8081/yoursecret
    • Setting for other cameras (e.g. PS Eye)
      • ffmpeg -i /dev/video0 -f mpegts -codec:v mpeg1video -bf 0 -s 640x480 -r 30 http://localhost:8081/yoursecret
    • Other possible settings:
      • -s 1920x1080 -r 30
      • -s 1280x720 -r 60
  • Terminal tab 3:

    • sudo pigpiod
    • cd rpi-control
    • python3
  • Terminal tab 4:

    • cd webapp
    • node server
  • Browser tab:

    • http://localhost:5000/
    • On other devices connected to the same network, replace localhost with ip (ifconfig) of rpi



  • Raspberry PI (tested with 3b+)
  • Camera. I used Raspberry PI camera v2, but also tested with PS Eye camera.
  • Laser pointer. I used this one.
  • 2 servos. I used 2 HItec HS-422 servos.
  • 6v accu pack for the servos.
  • pan-tilt set for servos. I used this pan-tilt set.
  • The RPI camera and laser pointer were mounted on the bracket.


Servo 1: (vertical servo)

  • Black: Ground pinout board
  • Red: 6v on pinout board
  • Yellow: BCM pin 13

Servo 2: (horizontal servo)

  • Black: Ground pinout board
  • Red: 6v on pinout board
  • Yellow: BCM pin 18

6v accu pack

  • Black: Ground pinout board
  • Red: 6v on pinout board
  • Ground pinout board: ground rpi


  • black: ground rpi
  • red: BM pin 4
You can’t perform that action at this time.