You probably already know the Arduino is a cool prototyping platform which allows you to build great projects with minimal effort. Over the years many contributors have designed compatible hardware and software libraries for easy methods to interact with the Arduino.

With the Crittergram Capture Cam we’ll combine several common components to create a camera that only takes pictures when critters move in front of it.

The Hardware

In this project we will connect the JPEG Camera module from RadioShack to the serial port on the Arduino Uno. We’ll also use a PIR (Passive InfraRed, learn more) sensor to detect motion. And lastly, we’ll use an SD card reader to provide storage for saving our images (the SD card doubles as a fast and easy way to transfer images to the computer).

If you look at the specifications of the camera module, you may notice it has a built-in motion detector. So why not use this instead of the PIR? Well, the camera module detects motion by changes in the image, so that a branch moved by the wind would make it take a picture. The PIR sensor works similarly, but by analyzing the infrared spectrum which is invisible to the human eye. That means it will only trigger if things are hotter (or cooler) than the general surrounding IR spectrum. Humans, most animals, even moving cars will trigger the PIR, whereas a swaying branch will not (this way we don’t end up with a memory card full of the same scene).

The Software

We’ve rated this project’s difficulty as easy due to the plug-and-play nature of the modules and the software provided. Essentially this project combines several pieces of software into one, including some of RadioShack’s provided sketch code with their JPEG Color Camera, modified to suit this build. See Steps 4 & 5 below for a verbose explanation of some of the routines and sub-routines used in the Crittergram Capture Cam sketch code.

You could easily take this project to the next level by turning it into a webcam (see conclusion), modifying the sketch code to take time lapse shots, or implementing an LDR or other method to take daytime-only shots, etc.

Sketch Code

Download the Arduino .INO sketch from MAKE’s GitHub:



Step #1: Format the SD card

Crittergram Capture Cam: Motion Capturing Camera
  • If you are not using a new SD card, make sure you don't have any files on there, because when we format it all the files will be erased. Insert the SD card into the slot on the SD card shield, and connect the shield to the Arduino. Make sure your pins line up correctly.
  • Download the sdfat library and install according to the included readme file. We are not actually going to use this library, but it comes with an example "SDFormatter" sketch, which we will use to format the SD card.
  • Now you can connect your Arduino to the computer. Then open the SDFormatter sketch from the menu File -> Examples -> SDfat. Upload the sketch and open the serial monitor to initiate. Confirm by sending Y for "yes" and then F for "erase and format." If there are no error messages your card will be formatted (this also ensures the Arduino is properly connecting to the SD card shield).

Step #2: Prepare the modules

Crittergram Capture Cam: Motion Capturing Camera
  • The JPEG camera comes with a quadripolar cord which we use to connect to the Arduino. Connect the female plugs to the module. The red wire connects to +5V, black to GND, brown to RXD and white to TXD.
  • For the PIR sensor, you will need 3 jumpers cables, also female to male. Again, connect the female plugs to the PIR sensor. The red wire connects to VCC, black to GND, and the blue wire connects to OUT.

Step #3: Put everything together

Crittergram Capture Cam: Motion Capturing CameraCrittergram Capture Cam: Motion Capturing CameraCrittergram Capture Cam: Motion Capturing Camera
  • Just to make sure nothing bad happens, unplug the Arduino from your computer.
  • NOTE: The illustration shows the modules plugged directly into the Arduino. Your pins will actually be plugged into the SD card shield. The I/O pins are the same if the shield is correctly aligned atop the Arduino. (For example in slide two the camera's 5V and GND pins are plugged into the SD card shield.)
  • Hook up the PIR sensor by connecting its GND, VCC and signal OUTput to GND, Pin 8 and Pin 7 on the SD card shield. The PIR module has a jumper labeled "S" & "L". Use it in "S" or "short" mode for sensing 15' or less, and "L" or long mode for sensing 15' - 30'.
  • Take the time to read over the JPEG camera module's manual. When you're ready you can install the module: connect Power (5V and GND) to their respective inputs on the SD card shield; follow the serial connections as illustrated (NOTE: the brown cable on the camera module connects to RX which connects to TX on the shield, and vice-versa for the white cable - this is all accounted for in the sketch code which we will examine later).
  • Reconnect the Arduino to your computer and open the sketch provided in the introduction.
  • To properly upload the sketch to your Arduino, disconnect the RX/TX wires temporarily from the SD card shield and the hit the upload button in the Arduino SDK (if the RX/TX wires stay connected you will get a generic upload error). After a successful transfer, reconnect the RX/TX wires and press the reset button on your Arduino once. Crittergram Capture Cam will boot up and start taking pictures after a few seconds. To access the images taken, simply unplug the Arduino and eject the SD card by firmly pressing it into the slot (it will pop out thereafter).

Step #4: Sketch Code

Crittergram Capture Cam: Motion Capturing Camera
  • The first paragraph of instructions is related to the camera module. Most of what is in there are definitions of hex-code instructions (all those 0x## values), which makes it more readable for humans. If you read the names of those variables it will tell you what they can be used for. A few of them aren't used in our code, but that's okay. Should you add code from the RadioShack examples, then it's all there (similar to how the original RadioShack code was modified for this project).
  • Next, we have a few instructions and variables which relate to the SD card module. It doesn't matter whether you use the SD card shield or the SD card reader on-board the ethernet shield (see Step 8), just make sure the value of SdChipSelect is defined according to your setup. myFile is the handler for our SD card access, while myFileName and myFileNr are used for storing the current filename and a counter (so it will record in ascending filenumbers onto the card).
  • The setup() routine is called once by the Arduino after booting up. First, it will begin to access the SD card, using the the pin number stored in the SdChipSelect variable.
  • Serial.begin() opens communication on the Arduino's dedicated serial port, with a speed of 115200 baud/s, which is the default baud rate of the camera module, and also the maximum speed available on this port.
  • After opening the port, the program sends the first command to the camera. The VC0706_compression_ratio() subroutine is called, with the argument 66. Why sixty-six you ask? And what is VC0706? The way this camera module works is to attatch a NTSC camera (hence the 640x480 resolution) to an Integrated Circuit (IC) called the VC0706, which allows us to freeze a video frame, compress it to JPEG and read it out digitally. And it will do that with the quality index of 66 (out of 100, or roughly two-thirds of the maximum quality) which we just instructed it to use.

Step #5: The Loop

Crittergram Capture Cam: Motion Capturing Camera
  • The loop() routine contains the code for the intended use of the camera. If you like to, this is where you can start modifying the code to accommodate your own needs.
  • You'll find a while loop, which will run and count up in the variable myFileNr for as long as it finds files on the SD card. Once it counts to a number with no corresponding file, it will break the loop and proceed with the program. This means it will never overwrite an existing file, even if you delete files in between. Be advised that deleting single files will disrupt the order of images taken, as all the files have the same creation date. This is due to the lack of a real-time clock in the Arduino, but nothing stands in your way to add one to the project.
  • Next, there is another loop, which basically let's the Arduino wait while the PIR sensor is not triggered. The voltage level on the digital input pin 7 is LOW in normal state, and turns HIGH once the sensor is triggered. The Arduino will check for that with a millisecond break in between.
  • Once the program exits this waiting loop, it will immediately take a picture. It does so by calling the capure_photo() subroutine, supplying a filename stored in the variable myFileName (determined in the previous Step).
  • All the subroutines following loop() are taken from RadioShack's sample code, with some modifications to the capture_photo() routine. The most obvious change to the original code is that we can specify a filename for the photo taken. If you want to start using the camera in your own projects, I recommend to copy "camera stuff" and "sd card stuff" from the beginning of the code, and all routines following the loop() routine. You can then call capture_photo() from anywhere in your code.

Step #6: Crittergram Housing

Crittergram Capture Cam: Motion Capturing CameraCrittergram Capture Cam: Motion Capturing CameraCrittergram Capture Cam: Motion Capturing CameraCrittergram Capture Cam: Motion Capturing Camera
  • Now put your project into an enclosure of some sort. We took the chance to explore RadioShack's new Project Enclosure Skeleton Kit with pre-drilled holes and cutouts (image 1). Depending on if you plan to place your Crittergram indoors or outdoors you may need to weatherproof your project.
  • Also depending on where you wish to place your Crittergram you can use different power sources. If your Crittergram is placed indoors you could easily connect the Arduino to your computer via USB or use an adapter plugged into a wall outlet. If you want more flexibility for where to place your project, you could use a mobile power pack, as long as the voltage output matches the power required by the Arduino.
  • Tidy up your cables with zip ties and use Supermount tape or hot glue to affix your modules into place on the enclosure's plexi.
  • TIP: Learn more about powering your project on the Arduino website; also see this 9V adapter mod for inspiration.
  • Another TIP: The skeleton enclosure kit allows you to strategically arrange all your boards, shields, and modules. You can then place the enclosure kit into whatever housing unit you have available, and all you have to do is drill two holes for the camera lens and PIR sensor to poke out (image 3). Ideas include placing the Crittergram in a birdhouse, camouflaging it inside a hollowed-out log, or building it into a book to hide on your shelves.

Step #7: Capture Critters in the Act!

Crittergram Capture Cam: Motion Capturing Camera


The Crittergram is a quick Arduino-based solution to build a VGA-resolution motion-sensing camera. Use a portable power pack and your project could be left alone for hours or even days.This project shows how you can easily combine shields and modules with the Arduino. Additionally, we've combined several pieces of software into one to suit our specific needs. This project can be easily modified or expanded upon (such as turning the Crittergram into a remote webcam, see below) for a novel Weekend Project of your own design.

Next Level: Remote Crittergram (using an Ethernet Shield)EthernetShield_bbSo how can we make it better? Let's hook up the Crittergram to our local area network, or even the internet! Arduino provides a shield, which comes with a web server built in. It also has a slot on-board to add a micro SD card. Once the ethernet shield is connected to your Arduino, you only need to hook up the camera and the PIR sensor, the same as described in the steps above. The pins needed are all being connected through the shield, the same as if you would plug it into the Arduino directly. If you are using our demo code for the webserver, please change the IP and MAC address, located in the first few lines of the code. Keep in mind that the sketch first saves an image to the micro SD card and then, when a client requests it, loads it again from the card- this means there are a few seconds delay between the image being taken and displaying on the computer requesting it.

Nick Normal

Nick Normal

I'm an artist & maker. A lifelong biblioholic, and advocate for all-things geekathon. Home is Long Island City, Queens, which I consider the greatest place on Earth. 5-year former Resident of Flux Factory, co-organizer for World Maker Faire (NYC), and blogger all over the net. Howdy!

  • Richard

    Hi, I may have done something wrong here but all of the jpegs are empty. I get “windows photo viewer can t display this picture because the file is empty” . I am using arduino Ethernet shield , changed sdchipselect to 4 and sd.begin to 4 but have nothing connected to the Ethernet. I have hundreds of empty jpegs.

    • Julius Schmiedel

      Hi Richard,
      what size do these jpeg’s have? also, can you find a test.jpg on your card?
      usually, if the arduino can’t “talk” to the camera, it doesn’t get past writing the test.jpg file.
      you could try to run radio shack’s code which is available on their website, to make sure the camera module is working properly.
      Best, Julius.

      • Richard

        Hi, Julius ,
        All files including test.jpg are 0 k. There were 658 0 k files. Am I supposed to load all 4 ino files or just the webserver since I have an arduino Ethernet shield. I have ordered the seeed SD card. I will replace the Ethernet shield with it and use the code made for the seeed SD shield.

        Thanks Again

        • Julius Schmiedel

          it seems that the camera module is not sending any jpeg data to write to the sd card, it’s an error that didn’t occur while i was developing the project, so i can only advise you to use what radio shack supplies in terms of documentation and code.
          if you are not using the ethernet capabilities (yet) you would use the code meant to run with the sd card reader shield, please note that in this case you need to change the pin again.


  • Jimmy

    how do i wire this with a OV7670 Camera Module Lens?

    • Julius Schmiedel

      Hi Jimmy,
      although the OV7670 looks interesting to use for this project, it doesn’t feature an internal JPEG compression which is needed for the project. you could replace the subroutine which takes the picture, as well as the “library” of functions from radioshack. but then only little of the code stays untouched, might be easier to work the other way, and include a sensor watching loop into code for the OV7670.

      Best, Julius.

  • Richard

    Ok , I got it to work using the Ethernet shield. Rx and Tx were wrong. I noticed if there is no movement it still places a 0 k jpg file and when there is movement I have a picture. I guess that must be the anticipated behavior. Thanks for the code. I may make a second one for the kids. LOL .

  • Karthik

    Is it possible to send the images to the web sever using a wi-fi shield? if so can you help me out?

    • Julius Schmiedel

      Hi Karthik,
      the arduino examples don’t feature http uploads, which means you could either implement this yourself after the notes in , or you might need to find another solution. if you haven’t got the webserver shield, yet, maybe the combination of the sd shield and a wifi-enabeld sd card works for you.


  • Sohel Malek

    I m making wireless surveillance based on zigbee technology..i have searched a lot but i thing this weekend project : will be very much useful for my project. My Doubt is that in the listing of PARTS that u have provide, in that parts JPEG Color Camera Board is OUT OF STOCK. So instead of this camera can i use MIniature TTL Serial camera by adafruit (
    Should i have to change code or rduino library if i change my camera?

    • Julius Schmiedel

      although the adafruit camera looks pretty similar, i would recommend to use the library that they supply. you would then have to modify those parts of code which call the function to take a picture, and replace the RadioShack libraries with yours.

  • Abu Rehla

    Hy Nick, may I capture pics without arduino?

  • Randy Cates

    This is great! I’m going to use it to find the critters stealing my tomatoes! Now I’d like to add a solar panel and battery and make it self-sufficient. Any suggestions as to the size of the solar panel and battery I should get?

    • Noorquacker Ind.

      I don’t recommend solar power, as it’s gonna be more expensive and not very trustworthy. Try using a few extension cords and a power adapter. And also maybe a switch, as you don’t want your crittergram to get wet.

  • pdeansmith

    Arduino Novice Here. Doing the Crittergram Capture Cam project. Getting an error message when verifying the sdformatter step.
    const unit8_l spi speed = spi_half_speed;
    What does it mean and where to next. Thanks, pdsmith

    • aa


  • super website and good ideas. I think solar is the way to go for the future, or water power, I think great posts in here

    • aa

      me tooo!

  • Chad Kennedy

    Excellent, I have used and tried all variants of the critter cam. Thank you guys for sharing your work. For my case, I had to figure out a few things, but that is expected as nothing always goes smoothly – was originally going off what RS had posted about the Camera, then found your article in Makezine.

  • Marc

    As Dr Frankenstein famously said “IT LIVES!” This is my first Arduino project and its very cool. I did have a few hiccups. I use Linux and was pleasantly surprised to find it well supported. SD shield was not working right but by checking mfr pages and changing the “SS” constant to “10” it started working.

    Thanks for the great article. And Thanks to a great sister who got me started on this.

  • Eric

    My 7yo helped put this one together, and it worked great (if you can forgive the image quality at any rate), after figuring out I needed to change the chipSelect from SS to 4 to match the seeed sd card shield.

    The only remaining issue I’ve got is that we’re using a 2G SD card, formatted FAT16, which means that we can only store 512 files at the root (or any single directory). After 512 pictures, it just gives up, even though there is tons of space available on the sd card.

    I didn’t see any obvious way to get directory counts using the SD library (other than iterating the directory every time), which would work, it just seems silly. FAT32 would solve this (or at least bump the limit up to 64k files). The SdFat library (and macos Disk Utility) both want to format the card FAT16 and not FAT32, however. Beating up the sdformatter example to always try to format FAT32 resulted in an error, so gave up on that route.

  • Rich

    I’m successfully writing files to the sd card, but they are all blank, 0 bytes. Their creation date is also incorrect–Jan 2000. Any idea why that may be?

    • Natasha

      I’m facing the exact same problem.
      I followed what you mentioned i.e. not to remove the sd card while the camera was writing yet I’m facing the same problem :(
      Any idea what should i do ?

  • Rich

    Follow up: Despite the warning to unplug the board before removing the SD, I did not. Removing the SD whilst the camera is writing corrupts the jpeg(s).

    Focusing this camera is a whole different story…

    • jc27310

      RIch, use the video out on the top edge of the board. you can view the feed on a tv and focus the camera without having to check the media to test the focus…

      • Noorquacker Ind.

        And it’s composite video, and go salvage an old graphics card. Very few have RCA video out, but you can just desolder it and use a wire to connect. It’s like you’re stalking someone!

  • James Dale

    Picture taken but with no image. When I have pictures taken they a 0 kb and are totaly blank. Any ideas?

    • Rich

      See my comment below. If you remove the SD card while the sketch is running, it corrupts the card, corrupting any attempts to write to it thereafter. You need to reformat the card with Sdfat (as described in the instructions).

      • James Dale

        I have not been able to get Sdfat or any of the Sdfat programs to work, I have tried 2 Windows 7 computers. Get get to the half speed and stops.
        Do I have to have the Critter Cam attached to the computer to use it.

        • Rich

          When you run sdfat, you should have your Arduino board plugged into your computer via usb. Whichever shield allows you to access the SD card should also be plugged in, and the sd card should be placed in the slot. Once this is done, upload the sketch to your board—once it is done uploading, go to tools>>serial monitor and follow the instructions.

          • James Dale

            This is how I have it set up.Do I need to be in administrator mode?

      • Noorquacker Ind.


        • couzzi

          Hm. Possibly? Although if I remember correctly, it’s the newly created images that get corrupted, not the incumbent contents. All the same, I’d advise getting those pictures off that potentially corrupted card ASAP.

  • John Marshall

    Cool works out of the box. I am using a variant of the 0706 but looks good. Question i have is what is the best way to get the SD card out so that it wont corrupt the data. I have used the old power off then release card but it still manages to cause issues with some files. Also another thing is the test file keeps writing back as well as old images how on earth dose this even happen after formatting. I would like to find a windows compatible file management solution so i don’t need to use sdformat all the time i am guessing that this is why i am having problems.

  • Patrick

    How fast will this camera take stills? Can it do 15 or 20 stills per second? I am looking for a solution that can be triggered by some IR sensor and take/store stills at 15-20 stills per second. It should NOT shoot video, but one still each time it is triggered. So very much like the Critter Gram Cam, only quite fast. TIA.

  • George Martini

    Perhaps stupid question… Project seems to work, but it only takes images that are zero length. Did I miss something? No one every adequately answered James Dale. I formatted my SD card etc. It is generating files, just no pictures. Help!

    • jc27310

      the zero length file is corrupted media. I fiddled with it for a while and read a few comments to find out that you MUST power down every time you inset or remove the media. Remover the jumper wires from the PIR and Camera, inser the card and start with the formatting sketch (format the media), then load the critter sketch. Power down and reconnect the jumpers. when you power up, you should be getting images. power down before removing the media to check for files.

      • Noorquacker Ind.

        This doesn’t work for me. I have 0 KB on the images EVERY time. Yes, it’s FAT32, but I can’t risk formatting it, as it’s my phones microSD card. And instead of a PIR sensor I use a little jumper between pin 6 and 7, which doesn’t exactly matter.

  • jc27310

    I figured the best way to focus this camera!

    Find the video feed on the top edge of the board. use some jumpers to connect to a RCA type jack (I used a couple of alligator clip jumpers), and connect the feed to a tv.
    the program will run and feed stills out to the video. you can now focus the camera without pulling the media and testing constantly!

  • Noorquacker Ind.

    I have a problem, please help.

    I just got the Camera Board and SD Card Shield and I use an SSD and a hard drive for storage. That’s why the Arduino directory is K:MasterAnKiptonio

    Arduino: 1.5.7 (Windows 7), Board: “Arduino Uno”

    Build options changed, rebuilding all

    K:MasterAnKiptoniolibrariesSDsrcutilitySd2Card.cpp:26:17: fatal error: SPI.h: No such file or directory



    compilation terminated.

    This report would have more information with

    “Show verbose output during compilation”

    enabled in File > Preferences.

    • Noorquacker Ind.

      FOUND IT! Just do #include at the beginning.

      • liam

        Where exactly do you have to add that, and is there any other library that you have to include

  • Levon Ravel

    I have just purchased the radio shack camera and now I am trying to stream the feed from the camera to the computer using and write. Have you tried doing this and if not would you happen to know how to accomplish this?

    Fixing an error on my part, I would like to transfer the capture image to pc via serial.println(bytes); I can decode the bytes pc side, Just lost on how the bytes are stored.

  • Levon Ravel

    okay I have made a ton of progress, I have now converted the raw data into hex and can serial port it to my c# application. I am running into problems and hope you see this soon.. this is my sketch and here Is an image of what is going on . I am not worried about welcome to OnixOne, I can’t figure out how to remove the V 2 V6 etc. What is that and how can I remove it?

  • Abdul Hafiz

    I try this project and still get picture with 0 kb picture.Maybe it cause by with different camera module.I am using Adafruit TTL Serial Camera.Is that my problem?

    • nsromero16

      Same here..I also have this problem and don’t know how to fix..

  • Andrew Mascolo

    Does anyone know how to save images as bmp instead of jpg?

    • alrui

      Use graphic converter or a similar program and convert them.

  • Aditya Gupta

    can i use another sd card shield?? (this sd card shield is sold out everywhere)!!!

    • alrui

      There are plenty on eBay, thats where I got mine & also Seed has an updated version on their website which should function as well.

  • Joseph Chrzempiec

    Hello does anyone know where i can find what sketch this camera uses by it’s self with whatever library it uses? can someone please help me out?

  • sliv5sliv .

    Go figure, I copy this entire sketch and it doesn’t work. Errors all over the place.

    • James Smallwood

      you have to unplug the wires befor you upload. read blog and you will see

  • David Bunger

    I get this error:

    Arduino: 1.6.3 (Windows 8.1), Board: “Arduino Uno”

    Build options changed, rebuilding all

    SdFormatter.ino:17:19: fatal error: SdFat.h: No such file or directory

    compilation terminated.

    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

  • rg33

    I was getting zero length files at first, but then added lines from the web server version of critter cam:


    pinMode(10, OUTPUT); // Change to 53 on ATMega


  • Eduardo Castellani

    Hello, thanks for the help.

    I ask your help as I want to send the pictures to my phone and my e-mail, how to code?

    Can you help me?

    Thanks and a hug

    Eduardo from Brazil

  • Dan

    I am getting this error.

    Arduino: 1.6.5 (Windows 7), Board: “Arduino/Genuino Uno”

    C:Program Files (x86)ArduinolibrariesSDsrcutilitySd2Card.cpp:26:17: fatal error: SPI.h: No such file or directory
    compilation terminated.
    Error compiling.

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.

    Thanks for any help you give me.

  • bobbyjhayes

    makezine jobs…. How Many Time You Lost This Droid Chance… If you wana get a reasonable income through laptop and if you have a reliable internet connection then you should be able to know how you make your income by laptop.this is very simple to know just vist my website.

    and sign up there for more details http://OneTimeAccess

  • alrui

    What did you guys use to stitch the individual jpegs into your “movie”?

  • alrui

    Now if only Chicken Shack could figure out how to have their search on their own site pull the products up! Might as well buy elsewhere since theyre inept! (surprised they didnt go bankrupt 30 years ago personally!).

  • alrui

    Are there any other camera boards that work for this project since the Radio Shack #276-0248 version is discontinued??? (in like 2014!).

  • alrui

    Anyone built this lately? I didnt realize this was a rather old project (not that it should matter). I gathered all of the parts and am going to give it to my son for x-mas. Im concerned about it going smoothly so as not to be a disappointment. Any input is appreciated.

    • Matt

      I got it to work fine with a Sparkfun Redboard. I had to add #include otherwise there was an error. Focusing was a pain. I put a mark on the barrel and made one full turn then checked the files. Repeated until it was clear.

  • Dan

    SdFat no longer works. Any suggestions? The error code is too long to post here. It would take up half of the page.

    • alrui

      Did you go here & dig around:
      I found one that works there but which one exactly I dont recall. If you still need help with it I can find the file and send it or at least a better link. Sorry but right now I’m in the middle of a few other projects.