I cannot see what is wrong with this simple code

Its pretty simple.

/*
  L298N Motor Demonstration
  L298N-Motor-Demo.ino
  Demonstrates functions of L298N Motor Controller


  DroneBot Workshop 2017
  http://dronebotworkshop.com
*/


int count = 0;
// Motor A


int enA = 12;
int in1 = 13;
int in2 = 15;


void setup()
{
Serial.begin(115200);
  // Set all the motor control pins to outputs


  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);


}


void loop()
{


Serial.println("Begin ");
 
  do
  {
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA, 1023);
  Serial.print("Count = ");
  Serial.println(count);
  count = count+1;
  } while (count < 4096);


  delay(20000);
  count = 0;
 
}

Yet it yields this error.

Count = 2710
Count = 2711
Count = 2712
Count
--------------- CUT HERE FOR EXCEPTION DECODER ---------------


Soft WDT reset


>>>stack>>>


ctx: cont
sp: 3ffffd80 end: 3fffffc0 offset: 01a0
3fffff20:  3ffe862e 00000000 25000a0d 40202d01

You are using a dleay(20000); which blockades your microcontroller for 20 seconds.

Depending on the exact microcontroller-type you are using such long blockation causes a watch-dog-timer-reset
(the "WDT" thing meantioned.

So what is the exact type of microcontroller you are using? ESP8266? or something else?

best regards Stefan

It's a Feather Huzzah, esp8266, and I didnt think that would make any difference.

What if you change your do…while to –

  do
  {
  yield();  // SOMETHING NEW ADDED
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA, 1023);
  Serial.print("Count = ");
  Serial.println(count);
  count = count+1;
  } while (count < 4096);

? ? ? ?

WDT - watchdog timer. It's a thing that, if it it not poked periodically, resets the chip. A bit like a dead-man switch. Options are:
1 - turn it off
2 - change the timeout on it
3 - turn your long delay into a series of shorter ones, and prod the WDT periodically
4 - code this thing without using delay.

PaulMurrayCbr:
WDT - watchdog timer. It's a thing that, if it it not poked periodically, resets the chip. A bit like a dead-man switch. Options are:
.
.
4 - code this thing without using delay.

Calling delay() on an ESP8266 allows all background tasks such as running the WiFi and tickling the watchdog to run. So, while it hurts responsiveness to user inputs and such, it's perfectly fine as far as the watchdog is concerned.

Try the suggestion in Reply #3. Calling yield() is essentially the same thing as calling delay(0);

Right.
I learned about yield() when I was using a really, really long millis-based timer.
It would bomb out but a delay-based would work.
The loop has to come around in about 2.5secs or it'll watchdog.
I don't know how to do it another way, the esp-purists dump on yield(). But it doesn't stuff up millis execution, that stays accurate.

gfvalvo:
Calling delay() on an ESP8266 allows all background tasks such as running the WiFi and tickling the watchdog to run. So, while it hurts responsiveness to user inputs and such, it’s perfectly fine as far as the watchdog is concerned.

Try the suggestion in Reply #3. Calling yield() is essentially the same thing as calling delay(0);

! I did not know that. I’m working with an ESP8266 at the moment, resetting the WDT explicitly. yield() sounds like a better solution.