I wrote this sample sketch to test serial communication with Arduino Leonardo (using Arduino IDE 1.0.5 on Windows 7):
int delayTime = 10000;
long lastExec = 0;
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
}
void loop()
{
long t = millis();
if (t - lastExec >= delayTime) {
if(Serial.available() > 0){
Serial.println('Hello world');
}
lastExec = t;
}
}
The serial port selected seems working because the sketch uploads correctly.
However I didn't get anything in the serial monitor window. Why?