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.
Materials
- 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
Instructions
Code
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.
Troubleshooting
- 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 in
myPort = 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.
- Arduino is also connected to the computer, and in
- 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.
- 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!