Back to tutorial index

Webcam Arduino Sweep for videoconference

This is a fast project on how to do a sweeping system for your labs webcam. You will only a few elements:

-Arduino Uno

-Medium size servo(FS5106B)

-Usb arduino cable

-3mm screws x4

-Jumper wires x3

-3d printed holder

-Computer to upload the code

-Webcam (our choice is Microsoft Livecam Studio as the mount is very usefull and it's awesome quality)

 

Assembling the hardware

You first need a support to hold all the parts,I suggest to download the 3dprinted object that I used as it is already tested and works well. With a normal FDM 3d printer you can setup almost all kind of values (from ultra quality to low) and it would work. Personaly I choose a medium one as the webcam is in a public space and has to look nice.

You should try to mount the servo motor in the holder, the choice of a big servo is due that is going to we working a lot of hours with an uncentered mass of inertia.So it is overpowered to make it last a long time.

Use the four screws mounts to hold it tight.

After that you can just press the Arduino Uno on the big space of the holder as it should hold itself under pressure.

Now it is time to connect the jumper wires to the servo. To make easy to identify each wire we chose red(positive +5v), black (negative) and white (data) The wires connection is :

-Jumper Red to Servo Red (or middle one)

-Jumper Black to Servo Brown

-Jumper White to Servo Orange

Is very important to don't mismatch the polarity of the wires or it could finish with and useless arduino board or servo.

Connect now the unconnected end of the jumper wires.

-Jumper Red to +5 Arduino

-Jumper Black to Gnd

-Jumper White to Pin9 (Digital)

Now it is time to screw the webcam to the servo rotating part.Use a 3 mm screw with a proper washer to keep it in place properly.

Hardware part finish!

Let's go with Software

For uploading the sketch to arduino you will need to install Arduino program.You can find it in the official ARDUINO WEBPAGE

After installing the program.Connect your arduino to the computer with the usb wire. It may take some minutes the first time to recognize the device.Switch on the program.

 

Go to FILE/EXAMPLES/SERVO/SWEEP

A need code may appear on your main screen.

This is the base code that we use for the webcam movement but by defect it is to fast and we want to make somes changes before uploading to the board.

Down here you can finde the code
/* WebcamSweep
 by EduardoChamorro 
 This example code is in the public domain.

 modified 17 Feb 2016
 Based on
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include 

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

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

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 90 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(2000);                       // waits 2000ms for the servo to reach the position
  
  delay(2000);          // waits 2000ms in 90 degrees position

  for (pos = 90; pos <= 180; pos += 1) { // goes from 90 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(2000);                       // waits 2000ms for the servo to reach the position
  }

  delay(2000);          // waits 2000ms in 180 degrees position
  
  for (pos = 180; pos >= 90; pos -= 1) { // goes from 180 degrees to 90 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(2000);                       // waits 15ms for the servo to reach the position
  }

  delay(2000);          // waits 2000ms in 90 degrees position
  for (pos = 90; pos >= 0; pos -= 1) { // goes from 90 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(2000);                       // waits 15ms for the servo to reach the position
  }
  
}

Once made the changes to the code or just copied this one in to your code. We have to tell the program witch exact arduino board we are using and witch port it is using.

Go to TOOLS/BOARDS/ and select Arduino/Genuino UNO

Now is turn to select the port that our arduino device is using.

Go to TOOLS/PORT/ and select the one that says Arduino Uno (the name may change a little bit depending if your arduino is original or not)

We are ready to update the code! UPLOAD THE CODE BY PRESSING THE UPLOAD BUTTON ON THE LEFT UP CORNER.Wait until the green bar says "uploaded"

See the magic happens!

Now just put some double side tape on the back,velcro or use screws to place wherever you want.