I'm using Arduino Uno controller
How it is possible to know if controller connected to PC via USB, to detect if wire is plugged and get condition for variable in sketch.
I've tried Serial.available(), but I'm not sure, if I can do it this way:
if (Serial.available())
{
val = true;
}
else
{
val = false;
}
I want use this condition to avoid setup() commands by some unexpected reason in case if controller powered only with adapter