Webcam Macrophotography
Although coupling a USB webcam to a compound microscope gives better results,
it turns out that at least some webcams are capable of close-up imaging themselves
without any additional optics.
How close a webcam can focus depends on the mechanical design of the lens mount,
focus tube, and the case and focusing ring. The basic rule of thumb seems to be:
the further you can screw the lens out, the closer the webcam will focus, and the
larger the image it forms on the sensor chip. Photographers have used this trick
for years with film cameras, putting an extention tube between the lens and
camera body to form what is known as a 'macro' setup.
I tried this trick before, with fairly good results.
However, I wanted to go further and see what the limits might be with this
technique. I bought a USB webcam from Radio Shack on clearance for $15. This
camera had a resolution of 640x480 pixels, and used a standard CMOS sensor chip.
Like the other webcam, the focus on this one could only be adjusted so far, limited
by the mechanical clearance between the housing and the focusing ring. To remove
this limitation I disassembled the webcam:

Webcam internals
The solder connections where the cable attached to the circuit board looked rather
fragile, so I provided a mechanical strain-relief by running a bead of hotglue over
the connections. Since the circuit board was also akward to handle, I attached it
to a short length of 3/4" diameter CPVC water pipe, again using hotglue. To finish
the initial conversion, I soldered a piece of discarded mouse cable to the terminals
of the push-button, and added another button switch to the other end. I then
zip-tied the cables to the CPVC pipe to provide additional strain-relief:

Webcam guts mounted and ready for use
The additional button allows taking images without jostling the camera itself, and
the CPVC pipe allows the camera to be clamped to a support stand for good stability.
How much magnification one can get out of this setup depends mostly on how far the
lens can be screwed out of the camera without falling totally out. However, the
more the lens is screwed out, the closer the subject has to be to the front of the
lens to be in focus, and the smaller the depth of field of the camera is.
In this case, even without the focusing ring there is still a plastic lip on the
edge of the lens assembly that makes getting the subject close enough to the lens,
and adequately illuminating it at the same time, a challenge. Here is an image
that illustrates this:

Ballpoint pen tip
The tip of this pen had to be pointed towards the lens to clear the plastic lip,
and the lack of good light can be seen in the general darkness of the image.
The focus isn't great either, but you can see the very narrow depth of
field (area where the subject is in focus) at this lens setting. Getting the
focus just right with the lens adjusted like this is a challenge.
An advantage of the macro setup is you can adjust the magnification of the
system simply by moving the camera and refocusing the lens. Here are two
examples:
Penny at two magnifications
Contrast these images with three images taken with my QX-5 USB microscope:
Penny at 10x, 60x, and 200x, using a QX-5 USB microscope
Though I have not measured it, a ball-park guess might put the webcam macro setup
somewhere in the neighborhood of 50x magnification. This is technically
out of the 'macro' range and into 'micro'. The images of the QX-5 are obviously
better, but the QX-5 was ten times the cost of the modified webcam.
This is fairly impressive performance for a $15 webcam, using only the optics
it came with. It won't put any commercial digital microscopes to shame, but
the price is hard to beat. Additions that would make this setup better
include an adjustable stage and an illumination system (most of these
shots were illuminated with a hand-held flashlight).
Links:
Webcam microphotography
Using a webcam as a microscope
http://micro.magnet.fsu.edu/primer/
http://www.microscopy-uk.org.uk/index.html
Microscope Photography
Digital Microphotography