Arduino LilyPad: Serial Communication Not Working

Hi. I have just recently configured my Eclipse to be able to work with the LilyPad (oddly enough part of the configuration I had to set the baud rate to 57600 and only works at this speed).

My problem is I have trouble getting the serial communication working. The simple code below does nothing:

void setup(void)
{
Serial.begin(9600);
Serial.print("Hello World!");
}

void loop(void) {}

Does anyone have any suggests to what may cause the serial comms to not work? Also, is there a reason to why the LilyPad only operates at 57600 in Eclipse? Thanks.

Because the baud rate on the arduino has to be the same as the system receiving it.

Try:
Serial.begin(57600);

instead and see if that works.

(At least, that's my guess.)

Nope. That did nothing as well. My code I also flash the light every second. The LED blinks fine and it seems that the LilyPad ignores the Serial.begin and Serial.print code.

My code I also flash the light every second.

Perhaps if you post your complete sketch..... use the # key to paste into a code window.

Lefty

Ok, but I'm working in Eclipse with C++.

File main.cpp

#include "application.hpp"

int main(void)
{
      Application app;
      app.run();

      return 0;
}

File application.cpp

#include "application.hpp"
#include "hardware.hpp"

//#define MAIN
#define PAUSE 300

void Application::run(void)
{
      for(;;)
            loop();
}

Application::Application()
{
      Hardware hardware;
      hardware.setup();

      Serial.begin(57600);
      Serial.print("Hello World!");
}

void Application::loop(void)
{
      #ifndef MAIN
            digitalWrite(LED_PIN, HIGH);   // set the LED on
            delay(PAUSE);                  // wait for a second
            digitalWrite(LED_PIN, LOW);    // set the LED off
            delay(PAUSE);                  // wait for a second
      #endif
}

File hardware.cpp

#include "application.hpp"
#include "hardware.hpp"

void Hardware::setup(void)
{
      pinMode(LED_PIN, OUTPUT);
}

Hardware::Hardware() {
      init();
      setup();
}

I left out the header files as they are just class abstractions.

Are you able to communicate with the Lilypad using a sketch compiled, linked, and uploaded using the Arduino IDE?

My mistake, it did work in the Arduino IDE (just didn't know how to use it). It just doesn't show up in Eclipse's console. Definitely something to do with Eclipse's configuration.

It looks like your Hardware::setup function gets called twice. Once, in Hardware::Hardware() and again in Application::Application().

You are right, I'll make the change. Thanks.

Do you have the clock rate and processor set appropriately in the Eclipse AVR settings? I spent HOURS trying to figure out a similar problem only to find that I had it set to the wrong speed.