I have this code. (Arduino UNO)
Everything is fine when I upload it (through USB).
Even if I reset Arduino it works. TX blinking and serial monitor print messages.
But if I reconnect USB (or unplug usb and connect 9v battery) TX not responding, TX led not blinking (nothing in serial monitor too).
Please help.
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
Serial.println("123");
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
}
plantsbook:
But if I reconnect USB
Hi,
Just to power the arduino?
Regards
Yes, just to power up.
So basically I just power off and then power on by reconnecting USB.
Hi,
Such a case I'd test with another simple sketch (blink) to check if it has to do with the "serial" instructions (it is quite probable).
Regards.
Blink example is blinking after reconnect,
but again nothing on TX, nothing on TX led and serial monitor.
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
// 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
Serial.println("123");
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Hi,
It sounds logical: on connecting to the PC probably it resets/reinitializes the USB at its own rate, while the arduino makes it (serial.begin) much quicker. As a result the communication brokes.
Although it is not advisable: try by inserting a delay berfore the serial.begin ...
Regards
Still the same behavior with 10 sec delay before serial begin.
plantsbook:
Still the same behavior with 10 sec delay before serial begin.
Hi,
Try by closing the serial monitor, connect the arduino then open the serial monitor ...
Anycase: apart from everybody learnig what the behaviour of the serial connection when doing that ... what is the practical interest for doing so?
Regards
I mean ... does it work when resetted (the arduino)?
Regards
It is same with closing serial.
Practical interest: it's alarm, and it expected to work from an external power supply, not from computer USB (and connected only first time).
plantsbook:
It is same with closing serial.
Practical interest: it's alarm, and it expected to work from an external power supply, not from computer USB (and connected only first time).
Does the "blink" work when connected to the battery?
Regards.
As I said it work when resetted,
but only for the first connection (when code uploaded).
plantsbook:
As I said it work when resetted,
but only for the first connection (when code uploaded).
It happens to me too.
I am not sure why it is so important to you.
Blink blinks with battery.
Blinks, but no RX/TX respond.
ieee488:
I am not sure why it is so important to you.
Because I want to place arduino in another place, so I need to unplug it from the computer and power it again later.
plantsbook:
Because I want to place arduino in another place, so I need to unplug it from the computer and power it again later.
I have done that too as have many others.
No problems.
.
TX LED is not the same as the LED on pin 13.
ieee488:
I have done that too as have many others.
No problems.
.
That is the question. Because mine doesn't work.
Maybe I burn it somehow?
ieee488:
TX LED is not the same as the LED on pin 13.
I understand that, of course.