USING SERVOS: PAN-TILT HEAD
FOR WEBCAMS
Here’s a quick project using 2 servos and an
Arduino: a pan-tilt head for a webcam. Hot-glue a
servo horn to the bottom of the webcam. Hot-glue
another horn to the side of one servo. Hot glue the
other servo to a base. Then plug all the servo horns
into the servos and you’ve got a pan-tilt webcam.
Figure H shows an example: a homebrewed network pan-tilt webcam built from an Asus wi-fi router
running Open Wrt Linux. Both the webcam and the
Arduino controlling the servos are connected via
a small USB hub to the router’s USB port .
The code to control 2 servos from the Arduino’s
USB/serial port is shown below. The sketch waits
for 2 bytes to arrive over the serial port, then treats
the first byte as the 0–180 value for the pan servo
and the second as the 0–180 value for the tilt servo.
#include <Servo.h>
Servo servoPan;
Servo servo Tilt;
void setup() {
servoPan.attach( 9); // pan servo is on pin 9
servo Tilt.attach( 10); // tilt servo is on pin 10
servoPan.write( 90); // home both servos to center
servo Tilt.write( 90); // home both servos to center
}
void loop() {
if( Serial.available() >= 2 ) { // two bytes waiting for us
int pan = Serial.read(); // 1st byte is Pan position
H
int tilt = Serial.read(); // 2nd byte is Tilt position
servoPan.write(pan); // move pan servo
servo Tilt.write(tilt); // move tilt servo
}
}
MODIFYING SERVOS FOR
CONTINUOUS ROTATION
Any servo can be turned into a bidirectional,
variable-speed gearmotor. Normally, controlling a
motor’s speed and direction requires a motor driver
chip and other parts. A servo already contains all
these parts. Hacking it is one of the best-known and
cheapest ways to get a digitally controlled gearmotor
for use in robotics — a continuous rotation servo.
The modification is part mechanical and part
electrical. The electrical mod replaces the pot with
2 fixed resistors of equal value. The mechanical mod
removes the stops that prevent the motor from
rotating fully.
I
NOTE: If you don’t want to open up a servo,
Parallax (maker of the BASIC Stamp) has a ready-to-use, standard-sized continuous rotation servo.
145 Make: