Counting contact bounce

I have no real experience with microcontrollers or programming, but I'm looking into the possibility of using an arduino in reliability testing. I have not purchased an arduino yet, so everything described here is hypothetical.

Desired Process:

  1. Starting low, a button is pressed which sends a high signal to the input of the arduino.
  2. Upon release (change from high --> low) I want to check for another switch activiation (low-->high-->low) within a given time (will count as bounce).
  3. If the switch bounces, I send a digital output as true for 1/2 second.

It seems very simple, but I was hoping someone could do a rough outline of a program that I could base mine off of. Also, any arduino product recommendations or helpful tips would be much appreciated.

You will get bounce on both the press and the release.
For the switch input, each time there is a change in state increment a variable. On the first change start a timer if there is more that a count of 1 within a certain time set the 1/2 second o/p.
What is it your are doing?

For my summer internship I'm working with reliability engineers. Currently they remove the switches being tested from the testing station every 250,000 cycles or so to test for contact bounce.

I am looking to make an easy way of keeping track of contact bounce while the switch remains in the testing station. This way if the arduino output is hooked up to a counter, on every bounce it would output high and the bounce would be counted. The counter could then be checked on specific intervals to track the switch degradation.

Obviously this could be improved upon, I was just looking for a base idea to start with.

This is code I used when investigating switch bounce and the effectiveness of hardware debounce.

const byte lfPin = 2;  //switch under test conneted to pin 2

unsigned long timer;
volatile unsigned long trans;

void setup()
{
    Serial.begin(9600);
    pinMode(lfPin, INPUT_PULLUP);
    attachInterrupt(0, ck, CHANGE);
    timer = millis();
}

void loop()
{
    if(millis() - timer > 500)
    {
        Serial.print(trans);
        trans = 0;
        timer = millis();
    }

}

void ck()
{
   trans++; 
}