Thursday, November 24, 2011

Ethernet Controller for Pan/Tilt Webcam with Arduino

During the last summer I found myself with a lot of time on my hands. One thing I really wanted to finish was a Pan/Tilt webcam mount and connect it to my ethernet shield on my Arduino. One day, I went out to the garage and started working on a set of "eyes" for my Rover 5 platform when it struck me that I hadn't finished the pan/tilt mount yet.

Once I finished the "eyes", you'll see a blog post on that build soon but this post is on the pan/tilt webcam.  I had a set of angle brackets left over from a DSLR Shoulder mount that I worked on with my brother-in-law, I might post an article on that someday as well. The brackets just happened to work out almost perfectly when I mounted a couple servos inside them with some double-sided tape.


After a couple days of googling for some example code, and finding something that somewhat resembled what I wanted to do, I decided to use that code and try to alter it for use with the servos. Turns out, this wasn't as difficult to do as I thought. In essence, the code for the Arduino just loops through waiting for a certain signal to come back. Once it receives the signal, it runs the appropriate subroutine. In this case, that subroutine is simply a servo command.

The page can be accessed from the intranet by navigating your web browser to the pre-defined address in the code. This displays a set of buttons that, when pressed, will control the movement of the servo. Originally, like you saw in the above video, the webpage had a set of buttons for moving the servos in step increments or in full movements. By full movements, I mean Full Left would move the servo to the  left completely. Well, as computers often do when we trust them too much, my hard drive crashed and I lost my latest revision that worked completely.

In my videos, I have information posted in the comments of how to contact me if you would like the code. One person wanted the code and I happily sent it to them. Not realizing until later that it was not the full code but rather just some code that had 5 buttons with step movements and a centering button. One thing I like is that the centering button checks to see where the servo is at, then figures out where it needs to go to be in the center position. It also moves slowly so that it doesn't look "jerky" on the video.

One last thing that I would eventually like to do is create a way for the Arduino to host it's own iframed web page so that the camera navigation could be separated from the video feed from the camera. When I attempted to put a uStream link of the video feed into the webpage and move the camera around the web page would refresh every time which meant that it was refreshing the video feed as well.

Currently, the movements are pretty basic and the functions are relatively easy to understand as well.

The current version of the code can be found here. If you have any questions or concerns, please let me know.

4 comments:

  1. is there any progress with this phrase?

    "One last thing that I would eventually like to do is create a way for the Arduino to host it's own iframed web page so that the camera navigation could be separated from the video feed from the camera. When I attempted to put a uStream link of the video feed into the webpage and move the camera around the web page would refresh every time which meant that it was refreshing the video feed as well."

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi, using your sketch for the controlling of the pan/tilt unit works great. Can you say something about getting the cam-video over ethernet into the webpage?
    Greetings Ulli

    ReplyDelete