Pages: 1 [2]   Go Down
Author Topic: I want to run command 1 tie to trigger webcam to take photo.  (Read 1353 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Each time you open the Arduino serial monitor window with the Arduino's serial port selected, the Arduino should reset. Does it do that?

Except on the Leonardo, if I remember correctly.

Yep.

http://arduino.cc/en/Guide/ArduinoLeonardo
Quote
Serial re-enumeration on reset.
Since the Leonardo does not have a dedicated chip to handle serial communication, it means that the serial port is virtual -- it's a software routine, both on your operating system, and on the Leonardo itself. Just as your computer creates an instance of the serial port driver when you plug in any Arduino, the Leonardo creates a serial instance whenever it runs its bootloader. The Leonardo is an instance of USB's Connected Device Class (CDC) driver.


This means that every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.


No reset when you open the serial port.
Unlike the Arduino Uno, the Leonardo doesn't restart your sketch when you open its serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.


This change means that if you're using any Serial print(), println() or write() statments in your setup, they won't show up when you open the serial monitor. To work around this, you can check to see if the serial port is open like so:



// while the serial stream is not open, do nothing:
   while (!Serial) ;
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12631
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Except on the Leonardo, if I remember correctly.


Yes, it seems that the Leonardo behaves substantially differently to the other Arduinos.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No sir,

When Arduino is connected to USB cable and
Code:
serial.println("Hello Arduino....")
command print data on serial monitor.

And when i upload the program again in same situation mentioned above then serial moniter is blank.

In next when I disconnect the USB cable and reconnect again to PC then only It will print that command.

In short Serial monitor works only after USB cable Reconnected to PC ...

What should be problem?
Is it java problem? I have Java updated latest.
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No reset when you open the serial port.
Unlike the Arduino Uno, the Leonardo doesn't restart your sketch when you open its serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.

Solution:
Code:
while (!Serial) ;
Put that in your setup routine
Logged

Pages: 1 [2]   Go Up
Jump to: