simple button request / led activation doesn't work

Hey there [=

I just started using arduino, and successfully applied the date-reset workaround for making my arduino uno [smd edition] work with my windows 8 laptop. I'm using a german book called "prototyping interfaces" and downloaded code and electronic assembly instructions from the related webpage www.prototypinginterfaces.com

Every time I upload a sketch to the board, the compiling takes one or two minutes and I get the following error message:

Couldn't determine program size: null

I don't know if this is relevant for my problem, but I wanted to post it anyway. The 'Hello World' blinking sketch worked fine, so I suppose it's no real problem.

Now this is the code I downloaded:

// global variables

// Button attached to pin 2
int ButtonPin = 2;
// LED attached to pin 13
int LEDPin =  13;
// current status of button
int ButtonState = 0;

void setup() 
{
  // initialize LEDPin as OUTPUT:
  pinMode(LEDPin, OUTPUT);      
  // initialize ButtonPin as INPUT:
  pinMode(ButtonPin, INPUT);     
}

void loop()
{
  // write value from ButtonPin into ButtonState
  ButtonState = digitalRead(ButtonPin);

  // if ButtonState is HIGH
  if (ButtonState == HIGH) 
  {     
    // LED = ON    
    digitalWrite(LEDPin, HIGH);  
  }
  // if ButtonState is LOW
  else 
  {
    // LED = OFF
    digitalWrite(LEDPin, LOW); 
  }
}

and this is the electronic assembly:

Instead of turning on when the button is pressed, and off when the button isn't pressed, the LED just blinks two times short, waits a second, then turns on for around a minute, then repeats all this. It doesn't react at all to the button. I also rotated and exchanged the button for another one, but nothing changed.

Maybe it's just a stupid mistake, but I can't make it out and also did not find anything with google, so maybe someone can help. thanks!

Change this line:

pinMode(ButtonPin, INPUT);

To this:

pinMode(ButtonPin, INPUT_PULLUP);

And the switch wiring as shown below.

SimpleSwitch.jpg

Now it just blinks every one or two minutes and still doesn't respond.

After I removed the resistor and connected the other side of the switch [where the red cable is connected in the graphic I posted] to GND, it works inverted. So the LED turns off when I press the button. It still does this doubleblink-one second pause- thing every one or two minutes.

With the code you posted, the LED can never blink.
Yes it works inverted as the input is now active low.
If you want the LED to come on with a button press, change as follows:

 // if ButtonState is HIGH means not pressed
  if (ButtonState == HIGH) 
  {     
    // LED = OFF    
    digitalWrite(LEDPin, LOW);  
  }
  // if ButtonState is LOW means pressed
  else 
  {
    // LED = ON
    digitalWrite(LEDPin, HIGH); 
  }

Get that going first, and you can then add switch debouncing later.

You're missing a resistor in the LED circuit.
You're using Pin 13 which has an onboard LED. This may be interfering with your LED. Try using a different pin for your LED.