Badr M
Published © Apache-2.0

Cam Trooper "the Physical WebCam Indicator"

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

BeginnerFull instructions provided3 hours139
Cam Trooper "the Physical WebCam Indicator"

Things used in this project

Hardware components

Photon
Particle Photon
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Plastic Enclosure, Junction Box
Plastic Enclosure, Junction Box
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Schematics

too simple for a schematic

Code

camCheckerMac.sh

SH
a shell script to check if the camera is on and invoke the service if it is
#!/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

moveTrooper.ino

C/C++
Particle photon file
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);



   // Particle.function("MoveTo", moveServoTO);  // create a function called "gong" that
  // can be called from the cloud
  // connect it to the gong function below

    myservo.attach(D2);   // attach the servo on the D0 pin to the servo object
//    myservo.write(25);    // test the servo by moving it to 25°
    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);       // move servo to 0° - ding!

    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");
}

Credits

Badr M
5 projects • 4 followers
Contact

Comments

Please log in or sign up to comment.