App: C is for Cookie


My dad, like the big blue friendly cookie monster, is a cookie lover. He is also a technology lover and a fan of "clever" dieting schemes. He's often talked of designing fridge locks or the like to prevent late night snacking. So this week, I wanted to program one of my boards to act as a calorie counter for each time he took a cookie out of a cookie jar as a possible christmas gift. The mechanics are simple, there just needs to be a count everytime the jar is opened (or closed, same #) and that count needs to be converted into calories.

I used my board from Electronics Design week, which has a button and and LED, although here we will just used the LED for the count. Below is the Eagle schematic.
25

And here is the board.
25

Then I wrote a program in Arduino that just took the button on pin 8 as the input, and counted each push (i.e. the lid of the cookie jar closing), and using the Serial library it communicated with the Processing Program. Below is the code in arduino.
25

And here is the code in Processing.
25
25

And here is the display screen after 1 push (note 1 McVittie chocolate biscuit, my dad's favorite = 120 cal) or 1 open and close of the cookie jar.
25

And here is the display screen after 2 pushes or 2 opens and closes of the cookie jar.
25

Update: there are two big problems here, 1 is that each time the jar is opened, the assailant can take multiple cookies and 2, this is a mean christmas gift.