A pretty useful technique you'll want to add to your collection of sketch-knowledge is how to keep track of button presses. Try this sketch:
Notice, we've added the ++ operator. Simply, the statement "buttonPresses++" increments (adds 1 to) the buttonPresses variable. This is a shortcut for "buttonPresses = buttonPresses + 1". We first saw this in the For Lesson from Chapter 5.
In this sketch there is no new code to explain. you should recognize several things from previous lessons that ave been put together in new ways. Now it's time for you to extend on some previous ideas.
The text and code examples above were copied and slightly modified from Arduino tutorials by Limor Fried at http://www.ladyada.net/learn/arduino under http://creativecommons.org/licenses/by-sa/2.5/ as such, this page is subject to the same license.