PunyCam: The Servo-and-LDR Based Camera

What does the world look like through the eyes of a light dependent resistor (LDR)?  My unimpressive PunyCam shows us the answer… ever so slowly!

I got the “2-DOF” servo gimbal quite a while ago because it was on sale. I didn’t have anything in mind for it, though, so it simply gathered dust. Then, one day, I wondered what would happen if I tried to take a picture using only a single LDR as a camera sensor.  LDRs have slow response times and a relatively wide angle, so it was obvious that without special optics it’ll be a rather poor image.  But how poor, exactly?

So I built a little voltage divider with the LDR and a 10K resistor, soldered it to a piece of Veroboard, covered the sensor with a length of black drinking straw to stop stray light from the sides, and mounted the thing on the gimbal like a tiny cannon.  The voltage divider output went into an “analog pin” on the Arduino, which also controlled the servo motions.

The simple Arduino code scans a predefined “view port” one column at a time from top to bottom, going back and forth on the X axis. At every point, it pauses for 10ms, takes a reading, converts it to 1-byte scale and sends {X,Y,Data} by Serial to the PC.  Of course, 10ms are not really enough for this kind of sensor, but even with this relatively short delay the process was almost too slow to bear. Also, adding time for the LDR to settle didn’t seem to improve the results much.

I did try to scan back and forth on the Y axis as well. That would have been far more efficient. However, the vertical line artifacts that plague the final image (see down below) were much worse when I scanned both ways.

Now, on the PC side I wrote a little program (using FPC/Lazarus) that reads the information from the serial port and simply draws it as oversized gray-scale pixels on the screen. For testing, I put a small plastic dog on a big battery, and set them in front of a strong LED light hoping that my “camera” will get a good shadow outline. Here’s the setup from the camera’s point of view – but of course, this image was taken using a proper digital camera…

The PunyCam's target, photographed with a proper camera
The PunyCam’s target, photographed with a proper camera

Remember that, because of the way the gimbal works, the final image will resemble a “fisheye” lens view rather than a regular picture. Still, with some imagination, you can certainly see the dog and the battery as shadows at the bottom center:

PunyCam image result
PunyCam image result

As I assumed at the beginning, this 90×100 pixel image is not too impressive (hence the name PunyCam – though it can be improved somewhat using image processing tools). However, It was a fun exercise and not a complete failure, so I’m happy with it 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × two =