LED blinking when it shouldnt.

I'm new to programing and Arduino.

I'm using the examples in the book and they work great. But the problem is that my LED is blinking when it shouldn't. I've changed the program many times. Different setups and pressed reset like 10 times. Nothing works. It doesn't interfare with my programs or codes. It's just annoying.

I hope my english is good enough to explain my problems?

I appriciate all answers.

//BC

Edit: I'm using windows 7 and bord model uno if that's important to know.

Please provide some details:

  1. what board are you using?
  2. Which LED, depending on the board there is LED_BUILTIN, Tx Rx
  3. What is your host platform MS Win, Linux Mac ?
  4. Include your code or a link to it.

dgerman:
Please provide some details:

  1. what board are you using?
  2. Which LED, depending on the board there is LED_BUILTIN, Tx Rx
  3. What is your host platform MS Win, Linux Mac ?
  4. Include your code or a link to it.
  1. Board Model: UNO R2
  2. I've used 3 different LEDs that came with the kit. I'm not sure if the kit have a special name.
  3. I'm using Windows 7
  4. I've used different codes that came with the instruction book. ISBN: 978-0-596-15551-3
#define LED 11


void setup()
{
  pinMode(LED, OUTPUT);
  
}

void loop()
{
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED,LOW);
  delay(1000);
}
#define LED 13
#define BUTTON 7

int val = 0;
int state = 0;

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);
}

void loop() {
  val = digitalRead(BUTTON);
  
  if (val == HIGH) {
    state = 1 - state;
  }
  
  if (state == 1) {
    digitalWrite(LED, HIGH);
  } else {
    digitalWrite(LED, LOW);
  }
}

My friends that have the same kit use the same code and don't have this problem.

EDIT: I've tried use different ports for the led. And it's still the same thing.

Are you using a pull-up (or pull-down) resistor?

If not, the LED will randomly change.

Example 2 add:
digitalWrite(BUTTON, HIGH);