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.

Sunday, November 20, 2011

Arduino USB Host Shield with USB HID Device

It's been a while since I last made an update, and for some reason I'm still seeing quite a few hits per month on the website. Along with that, I've been receiving quite a few requests for the code that I worked on to display the pot values of the left and right gimbals, the trim pot, and the numerical value for all the switches on a USB Realflight Controller.



When I set out to decipher these values, I had originally thought that I would use it to control a pan/tilt/roll mount that I'm creating for a friend of mine. I've since decided that I will instead use it to create a wireless controller for my Rover 5 robot that I purchased this summer.

Anyway, here is a link to the github repository where you can download the file. You are also welcome to email me if you have any question or concerns with the code.

When I have more time between my studies, I will update the status on the Rover project. It will hopefully be a lot of fun to play with and to use to terrorize my dog.