universe123
universe123

Reputation: 103

Arduino Can't run After Unplug and Replug or Reset

I am using Arduino nano 33 IoT and currently my Arduino stops running even the loop function after unplug&Replug into the computer without reprogramming or pressing the reset button. Any suggestions for resolving this issue?

Sample Code: The follow code stops printing "hello" to the serial port after unplugging and re-plugging or pressing the reset button on board.

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  while (!Serial);
}

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

Upvotes: 0

Views: 390

Answers (1)

universe123
universe123

Reputation: 103

I found the solution:

  1. Remove line while (!Serial);
  2. Reopen a new serial monitor whenever you reset/re-plugin in order to see the serial output!

Upvotes: 0

Related Questions