read/print out analog input values lilypad


I’ve got a little problem using my lilypad arduino.
I want to read/print out values from the sensor that i’ve connected to my arduino, with the arduino duemilanove this works fine. But in case I substitute the duemilanove by the lilypad (and change the board/serial) the values that are printed out are very strange. I’ve tried to change the baud, but i still get values like ‘???’ ‘A7#’ etc.
Is an extra line of code needed to read out values from the lilypad, according the serial port?

using: arduino - 0016 with OS x
am i a newbie: YES ;D

my code:
int sensorPin = 0; // select the input pin for the sensor
int tiltPin1 = 13; // select the pin for the actuators
int tiltPin2 = 12;
int tiltPin3 = 11;
int tiltPin4 = 10;
int tiltPin5 = 9;
int sensorValue = 0; // variable to store the value coming from the sensor

int clock = 998;
int min = 27;
int sec = 0;

void setup() {

// declare the ledPin as an OUTPUT:
pinMode(tiltPin1, OUTPUT);
pinMode(tiltPin2, OUTPUT);
pinMode(tiltPin3, OUTPUT);
pinMode(tiltPin4, OUTPUT);
pinMode(tiltPin5, OUTPUT);


void loop() {

sec = sec + 1;

// read the value from the sensor:
sensorValue = analogRead(sensorPin);

// stop the program for milliseconds:

//cyclus voor houding 1
//tiltmotors aanzetten
if (sensorValue > 750 && sensorValue < 800 && sec < 10)
digitalWrite(tiltPin1, HIGH);
digitalWrite(tiltPin2, HIGH);
digitalWrite(tiltPin3, HIGH);
digitalWrite(tiltPin4, HIGH);
digitalWrite(tiltPin5, HIGH);


//tiltmotors na bepaalde tijd uitzetten
else if (sensorValue > 750 && sensorValue < 800 && sec > 10)

digitalWrite(tiltPin1, LOW);
digitalWrite(tiltPin2, LOW);

//uitprinten van sensorwaarde en tijd

//regelaar voor minuten en secondes
if (sec > 59) {
sec = 0;
min = min + 1;

maybe an easier question: does a lilypad work on 9600 or 4800 baud?

thanks a lot!

Both probably, but does your software take account of the fact that the Lilypad is clocked at 8MHz, but the 2009 at 16MHz?


already worked it out. For persons with the same problem:

change the HardwareSerial.cpp and HardwareSerial.h for 8mhz for more information see this topic: