Close
0%
0%

Cam Trooper "The Physical WebCam Indicator"

A physical webcam status "sith"-indicator, increasing the awareness of being watched. (a 3 hours project)

Public Chat
Similar projects worth following
0 followers
With the current remote work situation the fact that the webcam is on might be often forgotten. In this weekend mini project I have built a physical Camera status indicator using Particle Photon and a Funco Sith Trooper, hopefully this would help reduce the possibility of potentially awkward situations by acting as a physical reminder of the camera status.

The Sith Trooper looks in your direction when the camera is on, and when it is off turns around, serving as a physical reminder that someone is watching you.

This was initially conceived as a mini weekend project with my 9 years old daughter I went for the simplest possible build using a bash shell script to detect the camera status and particle photon to move the Sith trooper. I repurposed an enclosure from a previous project with some modifications, and chose to make it battery powered to keep it as a self sufficient package.

It took me around 3 hours to build including many distractions and explaining the code / script to a 9 years old.

This build requires the following :

  1. Particle Photon Chip
  2. Micro Servo
  3. Li-Ion Battery (optional if you keep it connected)


Assembly:

Going for the simplest possible approach I went for direct wiring using female-female jumpers, thus bi-passing the need for a prototyping board or soldiering (safer given that a 9 years old was involved).

  • Servo Control went into D2
  • the rest is self explanatory (Ground to GND, power to power and so on.

CODE: 

To detect the camera status I used a simple bash script running on my mac, which I set to start running when I logged in using this guide. The script maintains the previous status and only calls the particle backend if the status changes. When you use it please change <DEVID> and <TOKEN> to your own.

This is built for Mac however this can also be ported over easily to windows machines.

#!/bin/bash
########
#Detect if camers is on, and if its on call webservice#
########


#log show --last 1m|grep "Post event kCameraStream"|tail -1

isCamOn=$(log show --last 15m|grep "Post event kCameraStream"|tail -1)
wasCamOn="a"

while true
do
  sleep 1;
  isCamOn=$(log show --last 15m|grep "Post event kCameraStream"|tail -1)


  if [[ $isCamOn == *"Stop"* ]]; then
    if [[ $wasCamOn == "no" ]]; then
      continue
    fi
    echo "It's stopped!"
    curl https://api.particle.io/v1/devices/<DEVID>/faceback -d access_token=<TOKEN>
    wasCamOn="no"
  #Cam trooper to look back
  elif [[ $isCamOn == *"Start"* ]]; then
    if [[ $wasCamOn == "yes" ]]; then
      continue
    fi
    echo "its ON"
    curl https://api.particle.io/v1/devices/<DEVID>/facefront -d access_token=<TOKEN>
    wasCamOn="yes"
  #Cam trooper to look front
  else
    echo "unkown status"
  #move left and right (trooper dance)
  fi
  sleep 1;
done

Moving the Sith-Trooper was as simple as moving the servo 180 degrees in each direction at a reasonable speed and then power off the servo (to reduce power consumption)

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position
bool FacingFront=false;

void setup()
{
    Particle.function("facefront", facefront);
    Particle.function("faceback", faceback);
    Particle.function("dance", dance);


    myservo.attach(D2);   // attach the servo on the D2 pin to the servo object
    pinMode(D7, OUTPUT);  // set D7 as an output so we can flash the onboard LED

     Particle.publish("Setup Module", "Starting", PRIVATE);
    //  system.sleep
}


int moveServoTO(int newPos)
{
    myservo.attach(D2);

    myservo.write(newPos);      

    Particle.publish("**Servo Moving TO **"+newPos, "position:"+ newPos, PRIVATE);

    delay(3000);

    myservo.detach();


        return 1;         

  //  return 0;
}

int facefront(String astring)
{
    if(FacingFront)
    {
        return 0;
    }
    moveServoTO(180);
    FacingFront=true;
    return 1;
}
int faceback(String astring)
{
    if(!FacingFront)
    {
        return 0;
    }
    moveServoTO(0);
    FacingFront=false;
    return 1;
}

int dance(String astring)
{
 return 1;
}

void loop()
{

    facefront("a");
    faceback("b");
}
 

Future Enhancements: 

  1. Properly wiring it (a bunch of resistors are required to secure the leads to the particle chip)
  2. Padding the box to reduce the servo sound 
  3. Adding more events and actions 
  4. 3D printing a better enclosure (smaller one)

  • 1 × particle photon
  • 1 × generic micro servo
  • 1 × Li-Ion Battery
  • 1 × Funco Pop Sith Trooper
  • 10 × Jumpers Electronic Components / Misc. Electronic Components

  • 1
    Connect the wires as shown

    Servo Control goes into D2

    the rest is self explanatory (Power to power, GND to ground and so on )

  • 2
    Load the code into the particle

    copy the code and use particle IDE to load it into your chip, test using the particle IDE to make sure that the servo is rotating

  • 3
    run the bash file on your mac

    the bash script should run in the background checking the webcam status and invoking the particle service as needed

View all 3 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates