Arduino Leonardo serial.println issue.

Hi All,

First I'd like to say that I'm entirely new to programming yet really hope - & look forward to - learn programming with the Arduino as a focus point. To that end I really appreciate that this forum and the Arduino community exists - many thanks :slight_smile:

To start out I recently bought an Arduino Leonardo (original), yet am having some issues with a couple of very simple program sequences found in the book "Beginning C for Arduino, Second Edition" - link here:

These program sequences are:

void setup() {
// put your setup code here, to run once:

Serial.begin(115200);
Serial.println("This is my first Arduino program!");

}

void loop() {
// put your main code here, to run repeatedly:

}

When running this small program (and a similar one which also uses the serial.println function) nothing shows up in the serial monitor. I have adjusted the baud rate to 115200 also on the serial monitor.

However, if I place the serial.println command in the void loop instead it writes "This is my first Arduino program" indefinitely. Which I think it should (right?).

So, I wonder if there's something with the Leonardo that is less compatible with the serial.println function?

Also, if this may be the case ... Is there any concensus at to which of the Arduino boards are considered the LEAST problematic one to use for "learning"? Being a complete newbie I prefer that the hardware/software interface just works flawlessly so that until I get more into the actual programming - and may learn about possible workarounds - I don't have to give such issues attention.

Thanks for any help you may be able to give :wink:

Jesper

Caveat: I don't have a Leonardo, and I don't own any Arduino books.

void setup()
{
  // start serial port at 115200 bps:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println ("Hello world!");
}

loop ()
{
}

(uncompiled, untested)

The Uno is easiest IMHO

Hi AWOL,

Thanks for your feedback :wink: ... When adding a "void" in front of the "loop" section your code works fine.

Thanks also for the feedback on the Arduino Uno - I will consider getting an Uno instead of the Leonardo - admittedly I'm entirely new to this and building skill and confidence in what goes on is important to me - and thus that the hardware/software interface just works so that I can focus on learning the programming part before addressing other potential issues.

Thanks again & cheers from Denmark :slight_smile:

Jesper

evalon:
When adding a "void" in front of the "loop" section your code works fine.

Well that's just embarrassing :frowning:

.. no worries 8) ... Made me think that I had learned something :wink: And it made it work, so thanks again!

Jesper