Cookie monster

We found out someone is eating the cookies from the jar in the kitchen! We thought about it and came to the conclusion that the best thing to do would be to prepare a trap to find out who was eating them. Let’s build something that will take a picture of whoever opens the cookie jar. No cookie monsters were hurt in the making of this experiment.


  • 1 Arduino Uno board
  • 1 Basic Education shield
  • 1 1M ohm resistor
  • 3 colored jumper wires (one long)
  • 1 TinkerKit Ultra Bright White LED
  • 1 TinkerKit wire
  • Webcam
  • Cookie Monster kit
  • 3-4 Rubberbands
  • 1 breadboard
  • Metallic cookie jar


  1. Attach the shield onto the top of the Arduino board.
  2. Connect TinkerKit Ultra Bright LED to TinkerKit digital port 9.
  3. Connect a 1 Mohm resistor between digital pin 3 and digital pin 2.
  4. Make a touch sensor by cutting a 20 cm x 20 cm square of aluminum foil. Wrap one corner of a foil square to a loose cable – the metal wire must contact the foil.
  5. Connect to digital pin 3.
  6. Build the Cookie Monster.
  7. Place the camera inside the head of Cookie Monster and place Ultrabright LED module into the mouth of Cookie Monster.
  8. Place your Arduino inside the monster’s body. Place the touch sensor in front of the Cookie Monster. Place the cookie jar on the touch sensor, making sure the metal parts are in contact.
  9. Connect the Arduino assembly to your computer and load the example CookieMonster.
  10. Move CookieMonster.pde from Processing Folder to the Arduino Libraries’ Processing folder and run it from processing.


You can find the code in File -> Examples -> Castilla -> Magic -> CookieMonster

You find the code you need to run in Processing to capture webcam images of your cookie thief in the same folder.

How it works

When you touch the cookie jar, the touch sensor is activated, and Arduino sends a “p” character to Processing through the serial port. When the Processing sketch receives this character, it takes a picture using the webcam.


  1. Processing is reporting error and no image is showing up? Make sure you have the latest version of Processing, and:
    • Arduino is also connected to the computer, and inmyPort = new Serial(this, Serial.list()[0], 9600);is using the serial port number of your arduino board. You can find it in the Tools->Serial Port of your Arduino IDE.
    • initializeCamera() is using a correct camera number from the list printed out by Processing.
  2. Touching the cookie jar and no image is captured? Try touching the touch sensor directly. If it’s working, you need a more conductive cookie jar. If not, see the capacitive sensor reference for debugging.
  3. Where’s the picture of cookie thief? Look into the CookieMonster sketch folder of Processing for it.

Experiment further

  • Make the monster wait for a few seconds before taking the picture, so you catch the thief with cookie in hand!