ESP8266 ISSUEs Running code

the blink app works perfectly, but when I add my program code it continuosly resets. anyone have any ideas?

The reset is in first image and the code below and I referenced all "new code" in comments

Original blink app

#define ledPin 2                       

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(ledPin, OUTPUT);              
}

// the loop function runs over and over again forever
void loop() {                       
  digitalWrite(ledPin, HIGH);             // turn the LED on (HIGH is the voltage level)
  delay(1000);                            // wait for a second
  digitalWrite(ledPin, LOW);              // turn the LED off by making the voltage LOW
}

New code


#define ledPin 2                        // New code
#define openWindowPin 16                // New code
#define closeWindowPin 5                // New code
#define openWindowBtn 4                 // New code
#define closeWindowBtn 0                // New code
#define maxClose 50  //centimeters      // New code
#define windowOpener "Window Opener"    // New code
#define maxOpen 6 //cm                  // New code
#define maxClose 44  //cm               // New code
int i=0;                                // New code
// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);                 // New code
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(ledPin, OUTPUT);              
  // Window Pins        
  pinMode(openWindowPin, OUTPUT);       // New code
  pinMode(closeWindowPin, OUTPUT);      // New code
  pinMode(openWindowBtn, INPUT);        // New code
  pinMode(closeWindowBtn, INPUT);       // New code
  pinMode(trigPin, OUTPUT);                     // New code
  pinMode(echoPin, INPUT);                       // New code
}

// the loop function runs over and over again forever
void loop() {                       
  Serial.print("loop ");                                      // New code
  Serial.println(i);                                             // New code
  digitalWrite(ledPin, HIGH);             // turn the LED on (HIGH is the voltage level)
  digitalWrite(closeWindowPin,LOW);         // New code
  digitalWrite(openWindowPin, HIGH);      // New code
  Serial.println("OPENING");                        // New code
  delay(1000);                            // wait for a second
  digitalWrite(ledPin, LOW);              // turn the LED off by making the voltage LOW
  digitalWrite(openWindowPin, LOW);      // New code
  digitalWrite(closeWindowPin, HIGH);    // New code
  Serial.println("CLOSING");                       // New code
  delay(1000);                       
  i++;                                // New code
}

Which Arduino board are you using ?

esp8266 not arduino

this reset is caused by WDT,
Possibly by delay(1000);
Try this code:

#define ledPin 2                        // New code
#define openWindowPin 16                // New code
#define closeWindowPin 5                // New code
#define openWindowBtn 4                 // New code
#define closeWindowBtn 0                // New code
#define maxClose 50  //centimeters      // New code
#define windowOpener "Window Opener"    // New code
#define maxOpen 6 //cm                  // New code
#define maxClose 44  //cm               // New code
int i=0;                                // New code
// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);                 // New code
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(ledPin, OUTPUT);              
  // Window Pins        
  pinMode(openWindowPin, OUTPUT);       // New code
  pinMode(closeWindowPin, OUTPUT);      // New code
  pinMode(openWindowBtn, INPUT);        // New code
  pinMode(closeWindowBtn, INPUT);       // New code
  pinMode(trigPin, OUTPUT);                     // New code
  pinMode(echoPin, INPUT);                       // New code
}

// the loop function runs over and over again forever
void loop() {  
  yield();                     
  Serial.print("loop ");                                      // New code
  Serial.println(i);                                             // New code
  digitalWrite(ledPin, HIGH);             // turn the LED on (HIGH is the voltage level)
  digitalWrite(closeWindowPin,LOW);         // New code
  digitalWrite(openWindowPin, HIGH);      // New code
  Serial.println("OPENING");                        // New code
  delay(1000);                            // wait for a second
  digitalWrite(ledPin, LOW);              // turn the LED off by making the voltage LOW
  digitalWrite(openWindowPin, LOW);      // New code
  digitalWrite(closeWindowPin, HIGH);    // New code
  Serial.println("CLOSING");                       // New code
  delay(1000);                       
  i++;                                // New code
}

thanks but can you tell me why

delay() incurs yield() which resets the wdt, so that is not the cause.

please show the original code in post #1 if you want to post the new code, do that in a new post, now the whole thread makes no sense at all and can be of no help to others.

I already marked solution

and modified the original post, which removes the original code and only shows the solution. Now how is anybody going to see what you did wrong initially ? You can unmark the solution, you can modify the original post to show the original code, you can mark solution again. It is your thread, you can always modify what you posted, but like this it is of absolutely no use to anyone but you.

added

It still doesn't make sense, (and there appears to be a delay(1000); missing.
But my response was actually to this.

Possibly by delay(1000);

because that can not be the cause of a WDT reset, since it restarts the timer, so the 2.5 seconds will never elapse.
So it's great it's solved, but the cause has not been found.