Skip to content

When the USB is not connected and the COM port is not open, system crashes. #527

@stnih

Description

@stnih

When COM port is open ;

  • LED_BLUE is blinking.
  • Green led on when I press the button.

When COM port is close or USB unconnection ;

  • LED_BLUE blinking several times and stops.
  • Green led not working when I press the button.

System crashes when the com port is not open. How can we deal with this?

void setup()
{
	pinMode(LED_BLUE, OUTPUT);
	pinMode(LED_GREEN, OUTPUT);
	pinMode(USER_BTN, INPUT);
	
	SerialUSB.begin();
}

void loop()
{
	SerialUSB.println("Hello from app.");
	
	digitalWrite(LED_BLUE, !digitalRead(LED_BLUE));
		
	if (digitalRead(USER_BTN) == HIGH) {
		digitalWrite(LED_GREEN, HIGH);
	}
	else {
		digitalWrite(LED_GREEN, LOW);
	}
	
	delay(100);
}

Metadata

Metadata

Assignees

Labels

duplicateThis issue or pull request already exists

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions