It wasn’t long ago that faced with a controller project, you might shop for something with just the right features and try to minimize the cost. These days, if you are just doing a one-off, it might be just as easy to throw commodity hardware at it. After all, a Raspberry Pi costs less than a nice meal and it is more powerful than a full PC would have been not long ago.
When [Joe Coburn] wanted to make a pan and tilt webcam he didn’t try to find a minimal configuration. He just threw a Raspberry Pi in for interfacing to the Internet and an Arduino in to control two RC servo motors. A zip tie holds the servos together and potentially the web cam, too.
You can see the result in the video below. It is a simple matter to set up the camera with the Pi, send some commands to the Arduino and hook up to the Internet.
The serial protocol for the Arduino is simple: The Pi sends a numeric position followed by a P (for pan) or T (for tilt) at 9600 baud. A web server and some Python handle the interface to the Internet and the human.
We’ve certainly seen our share of similar projects. Some of them have been a bit larger.
Nicely done. Good tutorial. Is there a way to get the motion to be in smaller increments and smoother?
not with those servo’s. go for a stepper motor and a gearbox.
I mean those are dirt cheap servo. You don’t think good ones, maybe brush less, would be much better?
No idea hear, sounds like you’ve been there so just curious.
Try this for smooth http://pastebin.com/4bRtCYTz
I should probably add that because of the potentiometer inside most servos that they wear out. So depending on the application they may not be the best choice. But then again anything with moving parts will eventually wear out.
Yes, the movement could be much much smoother.
https://www.youtube.com/watch?v=yoy7H21KJS0
There should be link to the code in the description.
His pan gets tilted. Ick. Wouldn’t it be better to have the tilt get panned?
Full ack. Although it would be a little bit more complicated to mount that way, the result would be more like you expect a pan-an-tilt can to work.
Why use arduino just use raspberry gpio to control servos.
Exactly my thoughts!
By having tried moving servos from a Pi, in the same time you arrive to install all, read docs, manage to find why PWM(10) don’t move the servos not even barely, risking to burn the Pi because two servos may eat too much, making a simple circuit with caps an diodes to avoid any possible harm to the Pi, …. you are already partying with beer because you slapped an arduino micro at it, hacked an example sketch, wired two cables and that’s good enough.
The servos need 5v, so you need a NPN transistor and 2 resistors per servo. (ref: https://projectedneuralactivity.blogspot.com/2012/12/controlling-servo-using-raspberry-pi.html )
https://1.bp.blogspot.com/-bLybszfiZMc/UN9zIqVqcLI/AAAAAAAAAHc/-ZGBS-pDI14/s1600/connections.png
Although 2 transistors and 2 resistors are cheaper it does offer less flexibility. You could an Arduino to level shift to 5 volts in addition to adding an additional 14 digital I/O pins, 6 with PWM pins, and 6 ADC input pins (10 bit). which you can easily use from the RPi using nanpy ( https://github.com/nanpy ). ( ref: MagPi issue 8, page 12 https://raspberrypi.org/magpi-issues/MagPi08.pdf )
I figured everyone used this model.
http://www.thingiverse.com/thing:115972
Sounds like way too much hardware for moving a couple of servos. The RPI is way more than you need to do everything. This would be an interesting thing to ponder with an 8266 based board. Cut the price down from like $50 for an RPI with a memory card and $10 or so for the arduino to like $5 for an 2866 and some little pieces. Oh, and this would be wireless.