loop isolation

I just started to learn how to code and I use an lcd shield on my Arduino.

What I've tried to do is making a timer where each second appear on the LCD...

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LED CountDown :");

}

void loop() {

 lcd.setCursor(0, 2);
 lcd.print(millis()/1000);
}

...while making an LED blink ON for 4sec and OFF for 7sec in a loop.

void setup() {

pinMode(2, OUTPUT);

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LED CountDown :");

}

void loop() {

digitalWrite(2, HIGH);
delay(4000);
digitalWrite(2, LOW);
delay(7000);

}

I tried to isolate the delay fonction with While loop but it's still affecting the LCD by applying to it the delay assigned for the blink of the LED.

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {

pinMode(2, OUTPUT);

lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("LED CountDown :");

}

void loop() {

 lcd.setCursor(0, 2);
 lcd.print(millis()/1000);

 int var = 0;
 while(var < 1){
digitalWrite(2, HIGH);
delay(4000);
digitalWrite(2, LOW);
delay(7000);
 var++;
 }
}

I search a lot but I didn't find anything to isolate a loop.

Hello and welcome,

Look the Blink Without Delay example for a non blocking method. Also look this post.

First, please modify your post and get rid of that awefull color that makes it hard to read. Then use code tags to post your code (the </> button).

Like guix stated, look at the Blink without delay example in the IDE.

Thanks a lot you very much for your help Guix!

Have a look at the demo Several Things at a Time

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

...R