Error Uploading to Arduino Uno (programmer is not responding)

I am trying to figure out why this happened and how to fix it. Here is the deal:

Board: Arduino Uno R3

Current Set Up: I have 12V DC going through a switch on a breadboard to pin 12, which I set as input. The code is telling the arduino to activate its onboard LED every 4 presses on the switch.

Code:

// Define Variables

// Button/Pedal activation set to Pin 12
const int button = 12;
//Button States
int buttonstate = 0; //variable for reading the pushbutton status
int lastbuttonstate = 0; //current state of the button
int buttonpushcounter = 0; //counter for the number of button presses

int led = 13;

void setup() {
//initialize button pin as input
pinMode (button, INPUT);
//initialize solenoid pins as output
pinMode (led, OUTPUT);
}

void loop() {
//read the state of the pushbutton values:
buttonstate = digitalRead(button);
// compare the buttonState to its previous state
if (buttonstate != lastbuttonstate) {
  // if the state has changed, increment the counter
  if (buttonstate == HIGH) {
    // if the current state is HIGH then the button went from off to on:
    buttonpushcounter++;
  }
}
lastbuttonstate = buttonstate;
//check if the number of button presses is divisible by 4
//if it is, we turn on each solenoid with time delays between them
if (buttonpushcounter % 4 == 0) {
  digitalWrite (led, HIGH);
}
else {
  digitalWrite (led, LOW);
}
}

Error:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x02

This error occurred after several trials of this code with slight modifications. I thought the Uno was rated for 12V DC, but now I am thinking that I may have been mistaken. Did I fry some components?

12v on the barrel jack or Vin? Ya that's fine.

12v on any other pin? That's not okay.

The not in sync error is the least useful error ever - it is completely non-specific; it could mean bad connections, bootloader problems, something is connected to TX, RX or RST pins and interfering with communication or autoreset (disconnect things from pins 0 and 1 before uploading)... really just about any problem in the upload process will give the same error.

okay, thanks. Now, as far as the error message goes, I tried this same setup with a different Uno and it was sort of working for a little while and then I got the following error:

avrdude: verification error, first mismatch at byte 0x0000
         0x9c != 0x0c
avrdude: verification error; content mismatch

Would this narrow down the list of possible problems I could be experiencing?

What do you mean when you say tried the same setup with a different UNO? Did you connect one of the pins to 12v?

Yes, connected 12V DC to Pin 12.

At the top of this Installation and Troubleshooting forum are sticky posts. Have a look at the Loopback Test Instructions. Test the USB-to-serial part of your UNOs to make sure that part works.

If they pass the test, it is a reasonable good bet you can just replace the ATmega328P-PU chips to get them going again. They should cost roughly $3.00 to $5.00 USD each. If you find chips which have the UNO or Duemilanove bootloader pre-loaded on them, it would save you the trouble of programming them. If you get blank ones, that is ok too, but you will need another working Arduino to use as an ISP programmer, or you will need an ISP programmer device, to burn the bootloader onto the blank chips.

If you get chips with Duemilanove bootloader on them, in the Tools, Boards menu you would need to select Duemilanove instead of UNO. You can use ISP programming to upgrade it to an UNO by burning the bootloader.

I do not recommend buying ATmega328-PU, be sure to get ATmega328P-PU.

Bootloaded chips http://www.dipmicro.com/store/CPU-ARD328P

good day master programmer can you help me how can i resolve my problem .. im using arduino UNO R3 8 channel relay with bluetooth control HC_05.. but after uploading there is an error like this.. avrdude: stk500_getsync() : not in sync: resp=0x00 can you help me how to resolve this error