Help with simple interval timer.

I've copied and modified the script in this post with an attempt to create an interval timer.
Right now I'm only looking for a beginning and an endding time. Two inputs.
A single or a series of push button spring loaded switches are attached to
5V and ground along with PIN 2. I also used a 1K resistor prior to ground.

When I push on the button I get a stream of data from PIN 2.
How can I collect just two inputs?

const int buttonPin = 2;     // the number of the pushbutton pin
unsigned long timeTotal = 0;
unsigned long time0;
unsigned long time1;
int count = 0;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  Serial.begin(9600);
  // initialize the LED pin as an output:

  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if ((buttonState == HIGH)&&(count==1)) {     
            if (count==1) 
              {time1 = micros();    time1 = micros(); 
                Serial.println("BUTTON DOWN 1"); 
                   count=0;
              }
     

      }
  
  
  
  if ((buttonState == HIGH)&&(count==0)) {     
       if (count==0) {time0 = micros(); 
            Serial.println("BUTTON DOWN 0"); 
          count++;
       }
 
      }
  
  }

Read this before posting a programming question

Code tags please.

When I push on the button I get a stream of data from PIN 2.
How can I collect just two inputs?

Read this about detecting transitions: Gammon Forum : Electronics : Microprocessors : Switches tutorial

 if ((buttonState == HIGH)&&(count==1)) {     

if (count==1)

count would always be 1, wouldn't it (in the second "if").

Ya. I'm nit sure why I did that. Bad move.

thanks for the link. this is excellent reading!!
give me some time to play around then I'll post if I solve the problem.

A single or a series of push button spring loaded switches are attached to
5V and ground along with PIN 2. I also used a 1K resistor prior to ground.

This description makes no sense. A schematic would be necessary.

Using the internal pullup resistor, and connecting one leg to ground and one leg to the pin would be simpler.

PaulS:

A single or a series of push button spring loaded switches are attached to
5V and ground along with PIN 2. I also used a 1K resistor prior to ground.

This description makes no sense. A schematic would be necessary.

Using the internal pullup resistor, and connecting one leg to ground and one leg to the pin would be simpler.

Thanks for the help.
This is the simple schematic. I’ve still got a lot to learn about Arduino. I rely do not understand the concept of a pullup resistor.[among other things]
All I want to do is have an arduino become and interval timer. I’m also experimenting with photo resistors and IR.

button_schem.png

1885:
I rely do not understand the concept of a pullup resistor.

The resistor gives the pin a "default" state, rather than an undefined state, if the switch is open.