Introduction: Hacking a Keychain Digital Camera for Arduino Control
Photography options for the Arduino are few and far between. Webcams aren't practical for applications like kite photography or public photography, unless you feel like buying a 200 foot USB cable. And current techniques for stand-alone Arduino photography typically try to capture raw image data from CMOS cameras popped off of cell phones...and believe me, unless you need to digitally upload or alter those photos in real time, you don't want to go down that road. Why isn't there a normal, cheap, run of the mill digital camera that's controllable by Arduino?
Turns out there is at least one - and they sell it at your local drug store (CVS/Rite-Aid/Walgreens/etc.)
It's those chintzy little keychain cameras that they sell for $10-15 a pop. The photography on them isn't half bad with a resolution of about 300 by 200, they can store between 20 and 240 photos (depending on the one you find), and it turns out the little guys were just made to be hacked. You can also do this same hack with a cheap 1 or 2 megapixel camera that takes SD cards if needed (see below), but we'll be stepping through the process used on the more commonly found 300 by 200 cameras.
This Instructable will walk you through the process of disassembling, modifying and reassembling an off-the-shelf keychain camera. It will then walk you through wiring a simple set of transistor switch circuits that can be used by Arduino to turn the camera off and on and snap photos whenever your program desires. It'll also have sample code and plenty of pretty pictures.
Before we start, a few notes:
*The camera being hacked may change from blue to silver and back in the photos. Don't fret, the internals of both cameras are the same (I'm working with both at the moment for research.). This same camera is sold across the country in different colors, under different brand names and even with slightly different physical casings.
*If this technique sounds familiar, it might be because what we're doing to the camera itself is very similar to the technique used by the CatCam, a project that went viral two years ago by putting small, time-lapse cameras on the collars of outdoor cats and watching where they go. The CatCam's technique uses a camera that's not easily available in the United States, and was written before Arduino really took off - hopefully this revisiting of the technique will help the DIY community rediscover and repurpose it in their projects. I discovered the CatCam as this project wrapped up, and both techniques were developed independently - so my technique likely varies from the CatCam technique; feel free to pick and choose techniques from the two.
*If you are outside the US or willing to order directly from CatCam, the hackable camera they sell is of a higher quality - 1 or 2 Megapixel - and can save photos directly to an SD card. Very nice for many projects (but not necessary for all.) But if you want a camera today, head to any Rite-Aid, CVS, etc and pick up the camera shown here - a Digital Concepts camera, usually distributed by Sakar international.
*My research actually has me controlling this camera via a stand-alone ATMega chip. If you're interested in learning that technique for some reason, let me know - if there's enough interest I'll whip up another Instructable. (I figured there'd be more demand for doing it via Arduino.)
UPDATE: By request I've added the circuit diagram to wire the stand-alone ATMega chip to the chip as the last photograph below. It won't be helpful for many of you, and I apologize for that - I hope to give this step its due diligence - but for those who are determined, it's better than nothing (I hope).
*This technique is being documented as part of my research at Carnegie Mellon University's Master of Tangible Interaction Design program, in Pittsburgh, PA. If you are considering going back to school, enjoy making things and are interested in the intersection of technology and design or art, drop us a line! :)
Hope you found this helpful - comments on both technology and application are welcome! Feel free to write me directly or comment if you have any questions or want any clarifications.
Turns out there is at least one - and they sell it at your local drug store (CVS/Rite-Aid/Walgreens/etc.)
It's those chintzy little keychain cameras that they sell for $10-15 a pop. The photography on them isn't half bad with a resolution of about 300 by 200, they can store between 20 and 240 photos (depending on the one you find), and it turns out the little guys were just made to be hacked. You can also do this same hack with a cheap 1 or 2 megapixel camera that takes SD cards if needed (see below), but we'll be stepping through the process used on the more commonly found 300 by 200 cameras.
This Instructable will walk you through the process of disassembling, modifying and reassembling an off-the-shelf keychain camera. It will then walk you through wiring a simple set of transistor switch circuits that can be used by Arduino to turn the camera off and on and snap photos whenever your program desires. It'll also have sample code and plenty of pretty pictures.
Before we start, a few notes:
*The camera being hacked may change from blue to silver and back in the photos. Don't fret, the internals of both cameras are the same (I'm working with both at the moment for research.). This same camera is sold across the country in different colors, under different brand names and even with slightly different physical casings.
*If this technique sounds familiar, it might be because what we're doing to the camera itself is very similar to the technique used by the CatCam, a project that went viral two years ago by putting small, time-lapse cameras on the collars of outdoor cats and watching where they go. The CatCam's technique uses a camera that's not easily available in the United States, and was written before Arduino really took off - hopefully this revisiting of the technique will help the DIY community rediscover and repurpose it in their projects. I discovered the CatCam as this project wrapped up, and both techniques were developed independently - so my technique likely varies from the CatCam technique; feel free to pick and choose techniques from the two.
*If you are outside the US or willing to order directly from CatCam, the hackable camera they sell is of a higher quality - 1 or 2 Megapixel - and can save photos directly to an SD card. Very nice for many projects (but not necessary for all.) But if you want a camera today, head to any Rite-Aid, CVS, etc and pick up the camera shown here - a Digital Concepts camera, usually distributed by Sakar international.
*My research actually has me controlling this camera via a stand-alone ATMega chip. If you're interested in learning that technique for some reason, let me know - if there's enough interest I'll whip up another Instructable. (I figured there'd be more demand for doing it via Arduino.)
UPDATE: By request I've added the circuit diagram to wire the stand-alone ATMega chip to the chip as the last photograph below. It won't be helpful for many of you, and I apologize for that - I hope to give this step its due diligence - but for those who are determined, it's better than nothing (I hope).
*This technique is being documented as part of my research at Carnegie Mellon University's Master of Tangible Interaction Design program, in Pittsburgh, PA. If you are considering going back to school, enjoy making things and are interested in the intersection of technology and design or art, drop us a line! :)
Hope you found this helpful - comments on both technology and application are welcome! Feel free to write me directly or comment if you have any questions or want any clarifications.
Step 1: Assemble Supplies and Tools
You'll need a few tools and supplies before you can hit the ground on this Instructable. Let's run through them now, shall we?
Tools:
*A tiny Philips-head screw driver. (About the size of one you might use to repair glasses, or in a computer repair kit.)
*Helpful, but not critical if you have long fingernails - a tiny flat-head screw driver to use as a plier.
*Wire cutter/wire strippers
*Helpful, but not critical - multimeter.
*Soldering iron and solder. (Now, now, don't fret. All you'll have to do is heat up some existing solder and stick a few stripped wire ends into the existing connections. Only rudimentary knowledge of soldering necessary. You might even be able to get away with wire glue on some models, but soldering is safer.)
Supplies:
*An off-the-shelf Keychain Digital Camera. Often sold under the brand names "Digital Concepts" or "Shift." Sold at CVS, Rite-Aid, Walgreens, some Walmarts, and all over the Internet.
*Helpful but not critical - a few spare AAA batteries. The camera should come with one AAA battery. But if you intend to use your project more than a few times or over long periods of time, you'll need spares - the camera eats them.
*A few feet of insulated wire. (Either normal-gauge plastic insulated, shown, or thin-gauge paint insulated is fine - both have their pros and cons; I tend to use paint insulated because I sometimes make custom male headers for my connections.)
*Breadboard or other protoboard.
*Two longish pieces of white wire (for connecting transistors to Arduino)
*Two longish pieces of black wire (for connecting ground from Arduino to breadboard)
*Two longish pieces of red wire (for connecting high power from Arduino to breadboard)
*Helpful, but not critical - an LED (for debugging output).
*Two transistors (I use NPN 2N3904 transistors.)
*An Arduino with USB cable.
Tools:
*A tiny Philips-head screw driver. (About the size of one you might use to repair glasses, or in a computer repair kit.)
*Helpful, but not critical if you have long fingernails - a tiny flat-head screw driver to use as a plier.
*Wire cutter/wire strippers
*Helpful, but not critical - multimeter.
*Soldering iron and solder. (Now, now, don't fret. All you'll have to do is heat up some existing solder and stick a few stripped wire ends into the existing connections. Only rudimentary knowledge of soldering necessary. You might even be able to get away with wire glue on some models, but soldering is safer.)
Supplies:
*An off-the-shelf Keychain Digital Camera. Often sold under the brand names "Digital Concepts" or "Shift." Sold at CVS, Rite-Aid, Walgreens, some Walmarts, and all over the Internet.
*Helpful but not critical - a few spare AAA batteries. The camera should come with one AAA battery. But if you intend to use your project more than a few times or over long periods of time, you'll need spares - the camera eats them.
*A few feet of insulated wire. (Either normal-gauge plastic insulated, shown, or thin-gauge paint insulated is fine - both have their pros and cons; I tend to use paint insulated because I sometimes make custom male headers for my connections.)
*Breadboard or other protoboard.
*Two longish pieces of white wire (for connecting transistors to Arduino)
*Two longish pieces of black wire (for connecting ground from Arduino to breadboard)
*Two longish pieces of red wire (for connecting high power from Arduino to breadboard)
*Helpful, but not critical - an LED (for debugging output).
*Two transistors (I use NPN 2N3904 transistors.)
*An Arduino with USB cable.
Step 2: Crack Open and Disassemble the Keychain Camera
First things first - you start off this hack by taking your screwdriver and fingernail/pliers to this camera and taking it apart. In the images notes below, you'll see a step by step dissection of the camera - I'll point out where each screw is located in the image notes. When your camera is disassembled and looks somewhat like the last picture (albeit with more pieces), continue to Step 3.
Step 3: Hack the Camera Part I (Solder Into the Switches)
This is the hardest part of the hack - but it's not *that* hard, I swear. So take a deep breath and let's get soldering!
For this hack, we will be leaving the camera circuit board entirely intact. All we will be doing is soldering our own connections into the circuit board on either side of the push button switches used to operate the camera. This allows us to use our Arduino to digitally "push down" on each button whenever we wish (via external transistors acting as switches).
When handling the circuit board, try to handle it by its edges whenever possible. The circuit board is fairly sturdy, but at the end of the day it is still exposed electronics, and it's worth not touching it directly any more than necessary.
Cut and strip the ends of four pieces of wire, each at least a foot in length. (Better longer than shorter in this case; this isn't something you'll want to redo too often.) Then, look at the two pairs of solder joints pointed out in the picture below, one pair around each of the two pushbutton switches. Using the continuity/short circuit function on your multimeter, you can confirm you've found the right pairs of joints to solder into by holding the ends to both switch joints and pressing the button manually to see if that creates a short between the joints. If it does (the resistance between the two drops from infinity to close to zero) you've found the right two. If you don't have a multimeter, you can just take a deep breath and trust the picture.
Once you're sure you've found the right joints, using your soldering iron, melt the solder at each of these four joints and attach an end of one of the four wire pieces into each of the four joints. If you have a helping hand on your soldering setup, by all means use it to hold your circuit steady (placing a small, folded piece of newspaper between the clamps to protect the circuit board.)
For this hack, we will be leaving the camera circuit board entirely intact. All we will be doing is soldering our own connections into the circuit board on either side of the push button switches used to operate the camera. This allows us to use our Arduino to digitally "push down" on each button whenever we wish (via external transistors acting as switches).
When handling the circuit board, try to handle it by its edges whenever possible. The circuit board is fairly sturdy, but at the end of the day it is still exposed electronics, and it's worth not touching it directly any more than necessary.
Cut and strip the ends of four pieces of wire, each at least a foot in length. (Better longer than shorter in this case; this isn't something you'll want to redo too often.) Then, look at the two pairs of solder joints pointed out in the picture below, one pair around each of the two pushbutton switches. Using the continuity/short circuit function on your multimeter, you can confirm you've found the right pairs of joints to solder into by holding the ends to both switch joints and pressing the button manually to see if that creates a short between the joints. If it does (the resistance between the two drops from infinity to close to zero) you've found the right two. If you don't have a multimeter, you can just take a deep breath and trust the picture.
Once you're sure you've found the right joints, using your soldering iron, melt the solder at each of these four joints and attach an end of one of the four wire pieces into each of the four joints. If you have a helping hand on your soldering setup, by all means use it to hold your circuit steady (placing a small, folded piece of newspaper between the clamps to protect the circuit board.)
Step 4: Hack the Camera Part II (Solder a Ground Connection)
You just completed the hardest part of this hack - congratulations! That said, you've got one more (easier) solder joint to make. This one you'll need some fresh solder for.
NOTE: Please ignore that in this picture, the circuit board is inside of the plastic front case. Don't do what it looks like I'm doing here - please solder this connection BEFORE putting the circuit back in its case, to avoid accidentally melting the plastic case. (I was simply sloppy in photographing this step and will try to fix it later.)
Take a fifth piece of wire, and cut it to at least a foot in length with edges stripped. Ideally, this piece of wire should be colored black, or at least differently from the first four. Now, solder one end of it to the outer side of the ground end of the battery holder, as shown. You'll need to add your own solder to this connection and solder directly onto the metal here. I've found this to be much easier than attempting to add your wire to the existing solder holding the battery holder to the circuit board. (I'll point out the right and wrong ways in the photos.)
Why are we doing this? Well, for an Arduino-controlled transistor to be able to control the switches on the keychain camera, the Arduino circuit and the keychain camera circuit need to share a common electrical ground. This wire simply lets you physically connect the camera's ground to the Arduino's ground later, via a common row on the breadboard.
NOTE: Please ignore that in this picture, the circuit board is inside of the plastic front case. Don't do what it looks like I'm doing here - please solder this connection BEFORE putting the circuit back in its case, to avoid accidentally melting the plastic case. (I was simply sloppy in photographing this step and will try to fix it later.)
Take a fifth piece of wire, and cut it to at least a foot in length with edges stripped. Ideally, this piece of wire should be colored black, or at least differently from the first four. Now, solder one end of it to the outer side of the ground end of the battery holder, as shown. You'll need to add your own solder to this connection and solder directly onto the metal here. I've found this to be much easier than attempting to add your wire to the existing solder holding the battery holder to the circuit board. (I'll point out the right and wrong ways in the photos.)
Why are we doing this? Well, for an Arduino-controlled transistor to be able to control the switches on the keychain camera, the Arduino circuit and the keychain camera circuit need to share a common electrical ground. This wire simply lets you physically connect the camera's ground to the Arduino's ground later, via a common row on the breadboard.
Step 5: Hook the Camera to Your Arduino
Now it's time to start hooking your camera up to your Arduino.
First, load some code that will control the camera to the Arduino.
Below, we've uploaded/attached some sample Arduino code that we've used here in order to take time-lapse photography. The code will turn the camera on, take a picture, and then delay for a full minute (during which time the camera will automatically power off) before powering back on and taking another picture - repeating this for twenty photographs (the capacity of my first hacked camera.)
Now, let's hook your Arduino to your camera.
First, a bit of explanation: to control the camera fully, our code takes two digital output pins and map one to the on switch, and another to the shutter switch. When the code wants to turn the camera on or off or switch modes, it briefly holds the camera on output pin high - and when the code wants to take pictures, it holds the camera shutter output pin high. This action is translated to the actual pressing of the button by turning a transistor on and off, which is in turn connected via our camera wires to the switches on the real camera. The grounds of the camera and the Arduino are linked to give the Arduino and external camera circuits a common ground, allowing the transistors to work properly.
Take two wires to connect these two output pins (camera on and camera shutter) to different lines on the breadboard. Then, connect the base pin of a transistor to each of the two outpit pins. Finally, connect your two wires for each corresponding switch from your actual camera to the other two (collector and emitter pins) of the transistor. You may have to experiment with which wire goes to the collector and which goes to the emitter in each pair; which is which will depend on the internal wiring of the specific camera you're hacking.
Finally, **and this is important**, take your ground wire from the camera and plug it into the ground pin on the Arduino. This is necessary for your transistors to work and thus for your camera to respond to your arduino!
First, load some code that will control the camera to the Arduino.
Below, we've uploaded/attached some sample Arduino code that we've used here in order to take time-lapse photography. The code will turn the camera on, take a picture, and then delay for a full minute (during which time the camera will automatically power off) before powering back on and taking another picture - repeating this for twenty photographs (the capacity of my first hacked camera.)
Now, let's hook your Arduino to your camera.
First, a bit of explanation: to control the camera fully, our code takes two digital output pins and map one to the on switch, and another to the shutter switch. When the code wants to turn the camera on or off or switch modes, it briefly holds the camera on output pin high - and when the code wants to take pictures, it holds the camera shutter output pin high. This action is translated to the actual pressing of the button by turning a transistor on and off, which is in turn connected via our camera wires to the switches on the real camera. The grounds of the camera and the Arduino are linked to give the Arduino and external camera circuits a common ground, allowing the transistors to work properly.
Take two wires to connect these two output pins (camera on and camera shutter) to different lines on the breadboard. Then, connect the base pin of a transistor to each of the two outpit pins. Finally, connect your two wires for each corresponding switch from your actual camera to the other two (collector and emitter pins) of the transistor. You may have to experiment with which wire goes to the collector and which goes to the emitter in each pair; which is which will depend on the internal wiring of the specific camera you're hacking.
Finally, **and this is important**, take your ground wire from the camera and plug it into the ground pin on the Arduino. This is necessary for your transistors to work and thus for your camera to respond to your arduino!
Attachments
Step 6: Take Pictures!
Plug a AAA battery into your camera. It should beep and turn on.
Wait 30 seconds for the camera to turn off. (The code I've included assumes the camera is already off when it is run, and will turn your camera on for you.)
Now, position your camera and Arduino for your desired viewing angle and turn on your Arduino. Voila!
Maybe you're asking - this camera is a little unwieldy, with an Arduino and breadboard and all. Can't we make this a little more compact, to take pictures from pretty much anywhere we want ?
The good news is, it can! This was designed for use as a stand-alone circuit, using the Atmega pulled off of an Arduino, on a single camera/circuit object which can be placed anywhere. I've included a picture of that setup below as well - and if folks are intrigued by it, I'll work on another Instructable or at least add the Eagle files to this page for others to work from. Just let me know!
Hope you found this helpful - comments on both technology and application are welcome! Feel free to write me directly or comment if you have any questions or want any clarifications.
Wait 30 seconds for the camera to turn off. (The code I've included assumes the camera is already off when it is run, and will turn your camera on for you.)
Now, position your camera and Arduino for your desired viewing angle and turn on your Arduino. Voila!
Maybe you're asking - this camera is a little unwieldy, with an Arduino and breadboard and all. Can't we make this a little more compact, to take pictures from pretty much anywhere we want ?
The good news is, it can! This was designed for use as a stand-alone circuit, using the Atmega pulled off of an Arduino, on a single camera/circuit object which can be placed anywhere. I've included a picture of that setup below as well - and if folks are intrigued by it, I'll work on another Instructable or at least add the Eagle files to this page for others to work from. Just let me know!
Hope you found this helpful - comments on both technology and application are welcome! Feel free to write me directly or comment if you have any questions or want any clarifications.