Definite newbie issue, please help a budding developer

I purchased an Arduino Uno yesterday. I am doing the button blink tutorial (led turns off when I push a button) the issue I am having is that whenever I push the button, the Arduino disconnects from my PC, causing it to lose power. I have a 20 second timer after the button press that I would like to run, but it isn’t working. Here is my code:

// constants won’t change. They’re used here to

// set pin numbers:

const int buttonPin = 2; // the number of the pushbutton pin

const int ledPin = 13; // the number of the LED pin

const int irsensor = 4; // The number of the pin for the IR sensor

// variables will change:

int buttonState = 0; // variable for reading the pushbutton status

void setup() {

// initialize the LED pin as an output:

pinMode(ledPin, OUTPUT);

// initialize the pushbutton pin as an input:

pinMode(buttonPin, INPUT);

// initialize the ir sensor pin

pinMode(irsensor, OUTPUT);

}

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 == LOW) {

// turn LED off:

digitalWrite(ledPin, LOW);

digitalWrite(irsensor, LOW);

delay(20000);

}

else {

// turn LED on:

digitalWrite(ledPin, HIGH);

digitalWrite(irsensor, HIGH);

}

}

The typical reason for the Arduino resetting like that is because you’ve shorted out the power (as in you are sending 5V straight to ground). If you haven’t done so already check out the tutorial for hooking up a button (it isn’t quite as straightforward as you may expect):

http://arduino.cc/it/Tutorial/Debounce

Yes, you are right, but I already figured it out.

My local Radio Slack didn’t carry long pole tact switches, so I bought a momentary switch with one pole. So, upon pressing the button power would cut. I went and bought some short throw tact switches to hold me over until my local electronics company opens for the week, and it works fine.

I can’t wait until tomorrow for my local hobby store to open so I can get some good equipment.

Thanks for the help, though.