Go Down

Topic: Leonardo doesn't talk to serial monitor (Read 2198 times) previous topic - next topic

wmassano

I have tried with two leonardos to get some serial I/O with the monitor and so far nothing. I can upload programs (blink, etc). When I upload the following with the while enabled, I get nothing--no serial output, no blinking. If I comment out the while, the led blinks. Any suggestions? (besides going back to the uno)
Code: [Select]
//Leonardo test 1 -- check serial i/o

void setup(){
  Serial.begin(9600);
  pinMode(13,OUTPUT);
//  while(!Serial);
}

void loop(){
  int i;
  Serial.println("Ready:");
  for(i=1;i<11;i++) {
    digitalWrite(13,HIGH);
    delay(500);
    Serial.println(i);
    digitalWrite(13,LOW);
    delay(200);
  }
}

Nick Gammon

The example code for the Leonardo serial port requires you to wait, for example:

Code: [Select]

//Initialize serial and wait for port to open:
 Serial.begin(9600);
 while (!Serial)  { }


Add in the line after Serial.begin and it should work better.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

wmassano

Already tried it. It still doesn't work. Whenever the while is enabled, the program never gets out of setup. Yet comm is okay since I can upload programs. I am at a loss.

Nick Gammon

Try a higher baud rate? I am using 115200 with mine. It gets converted into USB anyway.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

wmassano

Tried higher baud rate, still nothing. I am going to try an xp machine (this has been on Windows 7 up to now)

wmassano

UPDATE
The leonardo talks to the serial monitor on an XP machine. So my question is now: How do I get it to talk the serail monitor on my windows 7 machine????

mk3

Do you need brackets after this line?

your code above

while(!Serial);

like this instead

while(!Serial){}


wmassano

It works either way. In any case, the problem appears to be with windows 7. The leonardo communicates with an XP laptop, but not windows 7 via the serial monitor. I can upload to it with Win 7.

marklar

This may sound odd, but try changing this setting in your Serial object in your application:
RtsEnable =True
and try again.

I found the same issue on my (arg - Vista) machine, where it would work fine when talking with the Arduino serial monitor, but not my application.  I created a simple print and receive set of apps, and they didnt work.  I then updated the RtsEnable setting and amazed it started working.

Hope that helps

wmassano

Quote
This may sound odd, but try changing this setting in your Serial object in your application:
RtsEnable =True
and try again.

I'm not sure it applies. The problem is between the leonardo and the arduino serial monitor. Where would I put the code you suggest? It looks like code for an external program. Agian it is apparently a Windows 7 problem because I can see the leonado in XP.

marklar

Ah - in my case the serial monitor was working, just not my application.

wmassano

I am going to start a new thread to be more specific. Please look for that thread and do not answer this one. Thanks

Go Up