I want to run command 1 tie to trigger webcam to take photo.

Sir,

Actually I have made DTMF circuit. I want to trigger webcam because when i press key 5 from my mobile, DTMF circuit decode it and I want to take photo through webcam by sending command serially to MATLAB.

the following code is not print command on serial port 1 time. I want to run command 1 time only.

void setup() 
{
  Serial.begin(9600);
  Serial.println("|HELLO ARDUINO|");
}

void loop() 
{
   
}

My system configuration:
Windows Vista 32 bit / arduino leonardo hardware and arduino 1.0.4 IDE software

can u provide sample code for this?

No because you have not specified exactly what you want to do. If this is to connect a Webcam to an arduino and transfer a picture to aPC then not it can not be done. Processing power and lack of memory on an arduino prevent this.

Hello

i want to print command only 1 time on serial port.
for that i write that command in void setup to run it once as displayed below.

BUT IT DOES NOT WORK ??? and nothing is printed in Serial port…

CONFIG : Windows Vista 32 bit / arduino leonardo hardware and arduino 1.0.4 IDE software

void setup() 
{
  Serial.begin(9600);
  Serial.println("|HELLO ARDUINO|");
}

void loop() 
{
   
}

:
Please do helpful !!!

I don't know if you still need this for the Leonardo, but you might want to try it.

  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

Sounds like he only want to trigger the taking of a picture. MATLAB will do the actual capture.

Sorry, OP, I have no experience with MATLAB interfacing. It doesn't look especially difficult though since there is already support for a serial connection between MATLAB and Arduino: http://www.mathworks.com/academia/arduino-software/arduino-matlab.html

Sounds like he only want to trigger the taking of a picture. MATLAB will do the actual capture.

It does now he has edited that first post to make my answer look stupid. I hate it when some one does that, it is rank bad manners and bad for the forum as well. Some one searching is going to think that we don't know what we are doing.

when i run the below program for the first time it works fine.it writes command only once. BUT when I close the serial monitor and once again i run this code it will display nothing on serial port. Why this happens again and again??? i tried many times but running the code second time it does not write anything on serial port.

program:

void setup()
{
  Serial.begin(9600);
    while(!Serial)
    {
       ;
    }
 Serial.println("|HELLO ARDUINO|");
}

void loop()
{
 ;  
}

Sounds as if the Arduino is not resetting when you open the serial monitor. You could confirm that by watching the normal sequence of LEDs following a reset and see whether they occur when you open the serial monitor. I'm not familiar with the Leonardo but I understand it has some different behaviour relating to the serial port (such as the startup code that SurferTim mentioned) and I wonder whether it is expected to reset when the serial monitor is opened.

If I understand the (newly updated) description, your Arduino has a DTMF decoder which enables it to detect key presses from a mobile. (I have no idea how that works or whether it actually does work, but I'll make a working assumption that it does.)

You want your sketch to wait until it receives a specific DTMF input, and then print a command string to the serial port. You only want it to do this once after each reset. (Presumably you will physically reset the Arduino somehow to re-arm it).

In that case you just need to write some code in setup() that waits until the correct DTMF input is received and then prints your command string to the serial port.

I doubt it.

@yash92ec: Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the # button above the posting area.

Hello Sir,

But my problem is that when i run below code It will not print command on serial moniter everytime. Sometime it prints 1st time and next time not printed.

 void setup() 
{
  Serial.begin(9600);
  Serial.println("|HELLO ARDUINO|");
}

void loop() 
{
   
}

I also reset the arduino before uploading the program. But i doesn't work...

and i also want to ask that resetting the arduino hardware while program is uploading is good or bad ??

System: vista 32 bit arduino 1.0.4 software and JAVA 7u17 software(LATEST)

@ sanketec87 STOP CHANGING THE FIRST POST IT IS BAD MANNORS I have pointed this out before and you have done it yet again!!!

sanketec87: But my problem is that when i run below code It will not print command on serial moniter everytime. Sometime it prints 1st time and next time not printed.

I don't understand how that could be. If you reset the board, it will print that message. If you have a serial monitor connected with the correct serial port configuration, it will receive the message.

What do you mean by 'next time'? Are you resetting the Arduino - if so, how?

sanketec87: and i also want to ask that resetting the arduino hardware while program is uploading is good or bad ??

It's not going to damage the Arduino, but obviously it's going to cause the upload to fail to it's not generally a sensible thing to do.

When i run any serial command when arduino is plugged via USB cable it will prints that command.

but i doesn't print when i upload that program again.

and again when i reconnect the ardiuino board it will print that serial command.

In short Serial command is print only one time when Arduino board is connected 1st time to Laptop.

sanketec87:
When i run any serial command when arduino is plugged via USB cable it will prints that command.

but i doesn’t print when i upload that program again.

and again when i reconnect the ardiuino board it will print that serial command.

In short Serial command is print only one time when Arduino board is connected 1st time to Laptop.

I’m struggling to understand what you mean - I have no idea what ‘run any serial command’ means.

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

If you have the Arduino connected to the PC via USB and the Arduino serial monitor open with the Arduino’s serial port selected, and reset the Arduino using the reset button, the monitor should display that startup message. Does it?

PeterH: 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

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) ;

Retroplayer: Except on the Leonardo, if I remember correctly.

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

No sir,

When Arduino is connected to USB cable and 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.

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:

while (!Serial) ;

Put that in your setup routine