Go Down

Topic: Leonardo doesn't talk to serial monitor (Read 2 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.

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.

wmassano

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

Go Up