I just grabbed the version from the ones above here and made is somewhat smaller in terms of code. Feel free to use it in your Arduino app.
// This will store the last known state of the button
int lastButtonState = LOW;
void loop()
{
// Get the current state of the button
int currentButtonState = digitalRead(buttonPin);
// Has the button gone high since we last read it?
if (newButtonStatecurrentButtonState == HIGH && lastButtonState == LOW) {
// Switch the state of the output
digitalWrite(ledPin, !digitalRead(ledPin));
}
// Store the button's state so we can tell if it's changed next time round
lastButtonState = newButtonState;currentButtonState;
}