Errors in my program!

Hi!

I'm using a program, WiiCoasterUI, which is supposed to calculate G-force with the help of a wii-nunchuck controller.

When I'm trying to upload the program to an arduino microcontroller, I get these errors:

LCDSerial.cpp:30:24: error: WConstants.h: No such file or directory
LCDSerial.cpp: In member function 'void LCDSerial::begin(long int)':
LCDSerial.cpp:70: error: 'OUTPUT' was not declared in this scope
LCDSerial.cpp:70: error: 'pinMode' was not declared in this scope
LCDSerial.cpp:71: error: 'HIGH' was not declared in this scope
LCDSerial.cpp:71: error: 'digitalWrite' was not declared in this scope
LCDSerial.cpp: In member function 'void LCDSerial::print(uint8_t)':
LCDSerial.cpp:138: error: 'byte' was not declared in this scope
LCDSerial.cpp:138: error: expected `;' before 'mask'
LCDSerial.cpp:142: error: 'LOW' was not declared in this scope
LCDSerial.cpp:142: error: 'digitalWrite' was not declared in this scope
LCDSerial.cpp:145: error: 'mask' was not declared in this scope
LCDSerial.cpp:147: error: 'HIGH' was not declared in this scope
LCDSerial.cpp:155: error: 'HIGH' was not declared in this scope

I got no experience when it comes to program in C++, that is why I need your help.

Here is the program:

#define ledPin    13
#define lcdoutPin  7

#include "LCDSerial.h"

LCDSerial lcdSerial =  LCDSerial(lcdoutPin);

#include "wiichuck_funcs.h"

// sensor data in form:
// "|xxyyzz|xxyyzz|....\n"
// where 'xx','yy','zz'. are each a byte in ascii hex, 3-bytes per data payload
// terminated with newline
// every this many millisecs, read sensors, should be even mult of 1000
#define sensorUpdatesPerSec 10
#define sensorUpdateMillis (1000/sensorUpdatesPerSec)
#define SENSORBUFFSIZE (3*sensorUpdatesPerSec)

// overhead 
#define sensorUpdateMillisWFudge (sensorUpdateMillis - 10)

uint8_t sensorbuff[SENSORBUFFSIZE];
uint8_t sensorbuffidx;
uint8_t sensor_max[3];
uint8_t sensor_min[3];
uint8_t sensor_offsets[3] =   // zero-offsets, with initial guess
    {
        127,127,127
        //128,  // x
        //143,  // y
        //180   // z
    };
#define sensor_range 4   // wii nunchuck accelerometer is +/- 2g => 4g total
// see http://wiire.org/Chips/LIS3L02AL

#define BUFFSIZE 75
char buffer[BUFFSIZE];      // this is the double buffer
uint8_t bufferidx;

char timebuff[7] = "hhddss";

uint8_t i;
unsigned long lasttime;
unsigned long lastctrltime;
uint8_t disp_mode;   // 0 = rec/play, 1 = max, 2 = min, 3 = lat/ong
uint8_t rec_mode = 0;    // 1 = record, 0 = pause/stop
uint8_t key_down;
uint8_t display_gees = 0;

#define DISP_REC 0
#define DISP_MAX 1
#define DISP_MIN 2


void setup() 
{
    pinMode( ledPin, OUTPUT);
    digitalWrite( ledPin, HIGH);

    Serial.begin(4800);          // This goes to data logger
    Serial.println("WiiCoasterUI");

    lcdSerial.begin(9600);       // this goes to the LCD, don't change baud!
    lcdSerial.clearScreen();
    lcdSerial.print("WiiCoasterUI");

    wiichuck_setpowerpins();
    delay(100);
    wiichuck_begin();

    // initialize any data that needs to be specific values
    memset(sensor_max, 0, 3);
    memset(sensor_min, 255,3);

    delay(1000);
    digitalWrite( ledPin, LOW);
    lcdSerial.clearScreen();
}

// returns ascii hex nibble
static char toHex(uint8_t h)
{
    h &= 0xf;
    if( h < 10 ) 
        return (h + '0');
    return (h - 10 + 'A');
}

// take a signed number, format it as a string into buff
static void formatInt8(char* buff, int8_t v)
{
    buff[0] = (v>0) ? '+':'-';
    buff[1] = ((abs(v)/100) %10) + '0';
    buff[2] = ((abs(v)/10)  %10) + '0';
    buff[3] = ((abs(v)/1)   %10) + '0';
    buff[4] = 0;
}
// turn a signed float byte into a character string
// this likely has lots of bugs
void formatFloat8(char* buff, int8_t v, float range)
{
    buff[0] = (v>0) ? '+':'-';
    v = abs(v);
    float f = (v*range/127)/2;
    buff[1] = (int)f + '0';
    buff[2] = '.';
    buff[3] = ((int)(f*10) %10) + '0';
    buff[4] = 0;
}

// convert milliseconds to a hour/min/sec string
static void millisToTimeStr( char* buff, unsigned long millis )
{
    long secs = millis/1000;
    long mins = secs/60;
    int hours = mins/60;
    secs = secs % 60;
    mins = mins % 60;
    buff[0] = (hours/10)+ '0';  // hours tens
    buff[1] = (hours%10)+ '0';  // hours ones
    buff[2] = (mins/10) + '0';  // mins tens
    buff[3] = (mins%10) + '0';  // mins ones
    buff[4] = (secs/10) + '0';  // secs tens
    buff[5] = (secs%10) + '0';  // secs ones
    buff[6] = 0;
}

void loop()
{
    char c;

    digitalWrite(ledPin, LOW);
    
    unsigned long thistime = millis();
    // wait until it's the right time
    if( (thistime - lasttime) >= sensorUpdateMillisWFudge ) { 
        lasttime = thistime;
        digitalWrite(ledPin, HIGH); // turn off "good data" LED so it pulses
        
        // Acquire sensor readings
        wiichuck_get_data();
        for( i=0; i<3; i++ ) { // loop thru x,y,z parts
            uint8_t v = wiichuck_accelbuf[i];
            if( v > sensor_max[i] && v!=255 ) sensor_max[i] = v;
            if( v < sensor_min[i] && v!=0   ) sensor_min[i] = v;
        }

        // Save data
        memcpy(sensorbuff+sensorbuffidx, wiichuck_accelbuf, 3);
        sensorbuffidx += 3;
        if( sensorbuffidx == SENSORBUFFSIZE ) {
            sensorbuffidx = 0;  // just loop, what else we gonna do?
        }

        // Do UI Parsing
        if( wiichuck_cbutton() ) {      // C button == clear min/max
            memset(sensor_max, 0, 3);   // reset maxs to 0
            memset(sensor_min, 255,3);  // reset mins to 255
            display_gees = !display_gees;
            //for( i=0; i<3; i++ ) 
            //    sensor_offsets[i] = wiichuck_accelbuf[i];  // FIXME: wrong
        }

        if( wiichuck_zbutton() ) {      // Z button == stop/start recording
            key_down = 1;               // keydown is for debounce
        }
        if( !wiichuck_zbutton()  && key_down ) {
            rec_mode = !rec_mode;
            key_down = 0;
        }

        // pick display mode based on inputs
        if( wiichuck_joyy() > 0xA0 )         disp_mode = DISP_MAX;
        else if( wiichuck_joyy() < 0x40 )    disp_mode = DISP_MIN;
        else                                 disp_mode = DISP_REC;

        // move stick to the right changes readout style
        if( wiichuck_joyx() > 0xA0 ) 
            display_gees = !display_gees;

        // Write to LCD
        lcdSerial.gotoPos(0,0);  // line 1
        if( disp_mode == DISP_MAX )
            lcdSerial.print("Max");
        else if( disp_mode == DISP_MIN ) 
            lcdSerial.print("Min");
        else 
            lcdSerial.print( (rec_mode) ? "Rec":"Stp");

        lcdSerial.gotoPos(0,7);
        // if no time from controller
        if( thistime - lastctrltime > 5000 ) {
            millisToTimeStr( timebuff, thistime );
        } 
        
        // print out time
        lcdSerial.print( timebuff[0] );
        lcdSerial.print( timebuff[1] );
        lcdSerial.print( ':' );
        lcdSerial.print( timebuff[2] );
        lcdSerial.print( timebuff[3] );
        lcdSerial.print( ':' );
        lcdSerial.print( timebuff[4] );
        lcdSerial.print( timebuff[5] );
        
        lcdSerial.gotoPos(1,0); // line 2
        lcdSerial.print( (display_gees) ? "g:":"w:" );
        char buff[5];
        for( i=0; i<3; i++) {
            uint8_t v;
            if( disp_mode==DISP_MAX ) v = sensor_max[i];
            else if( disp_mode==DISP_MIN ) v = sensor_min[i];
            else v = wiichuck_accelbuf[i];
            if( display_gees ) {
                int8_t vo = v - sensor_offsets[i];
                formatFloat8( buff, vo, sensor_range ); // range is +/- 2g => 4
            } else { 
                formatInt8( buff, v - 127);
            }
            lcdSerial.print( buff );
            if(i!=2) lcdSerial.print(',');
        }
    }

    
    // Over serial, can ask for last 10 readings with 'sensor dump command'
    // get sensor dump commands from serial 
    int n = Serial.available();
    if( n > 6 ) {       // "s221359", 7 bytes 
        char c = Serial.read();
        if( c != 's' && c!='S' )  // command byte
            return;

        // do rest of parsing, for time
        for( i=0; i<6; i++ )
            timebuff[i] = Serial.read();
        delay(5); // this is needed or SoftSerial reading this will choke 
        Serial.print( (rec_mode) ? 'r':'s' );
        // fill buffer with text version of sensor data
        bufferidx = 0;
        for( i=0; i< sensorUpdatesPerSec; i++) {
            uint8_t si = (i*3);
            buffer[bufferidx+0] = '|';
            buffer[bufferidx+1] = toHex(sensorbuff[si+0]>>4);
            buffer[bufferidx+2] = toHex(sensorbuff[si+0]);
            buffer[bufferidx+3] = toHex(sensorbuff[si+1]>>4);
            buffer[bufferidx+4] = toHex(sensorbuff[si+1]);
            buffer[bufferidx+5] = toHex(sensorbuff[si+2]>>4);
            buffer[bufferidx+6] = toHex(sensorbuff[si+2]);
            bufferidx+=7;
        }
        buffer[bufferidx++] = '\r';
        buffer[bufferidx]   = '\n';
        buffer[bufferidx+1] = 0;
        
        Serial.print(buffer); // dump it out

        sensorbuffidx = 0;   // reset
        memset(sensorbuff, 0, sizeof(sensorbuff));

        lastctrltime = millis(); // say we saw a command
    }

}
/*
  LCDSerial.cpp - Sparkfun LCD Serial comm using simple software serial 
  2008, Tod E. Kurt, http://todbot.com/blog/

  Based on:
  SoftwareSerial (2006) by David A. Mellis and
  AFSoftSerial (2008) by ladyada

  Copyright (c) 2006 David A. Mellis.  All right reserved. - hacked by ladyada 

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/******************************************************************************
 * Includes
 ******************************************************************************/
#include <avr/interrupt.h>
#include "WConstants.h"

#include "LCDSerial.h"

#define LCD_CMD               ((uint8_t)0xFE)
#define LCD_CMD_CLEAR_SCREEN  ((uint8_t)0x01)
#define LCD_CMD_POS_LINE_ONE  ((uint8_t)128)
#define LCD_CMD_POS_LINE_TWO  ((uint8_t)192)

#define LCD_BACKLIGHT         ((uint8_t)0x7C)
#define LCD_BACKLIGHT_MIN     ((uint8_t)128)
#define LCD_BACKLIGHT_MAX     ((uint8_t)157)

#define putc(x) print((char)x)

static int _bitDelay;

#if (F_CPU == 16000000)
void LCDwhackDelay(uint16_t delay) { 
  uint8_t tmp=0;

  asm volatile("sbiw    %0, 0x01 \n\t"
	       "ldi %1, 0xFF \n\t"
	       "cpi %A0, 0xFF \n\t"
	       "cpc %B0, %1 \n\t"
	       "brne .-10 \n\t"
	       : "+r" (delay), "+a" (tmp)
	       : "0" (delay)
	       );
}
#endif


LCDSerial::LCDSerial(uint8_t transmitPin)
{
  _transmitPin = transmitPin;
  _baudRate = 0;
}

void LCDSerial::begin(long speed)
{
  pinMode(_transmitPin, OUTPUT);
  digitalWrite(_transmitPin, HIGH);

  _baudRate = speed;
  switch (_baudRate) {
  case 115200: // For xmit -only-!
    _bitDelay = 4; break;
  case 57600:
    _bitDelay = 14; break;
  case 38400:
    _bitDelay = 24; break;
  case 31250:
    _bitDelay = 31; break;
  case 19200:
    _bitDelay = 54; break;
  case 9600:
    _bitDelay = 113; break;
  case 4800:
    _bitDelay = 232; break;
  case 2400:
    _bitDelay = 470; break;
  default:
    _bitDelay = 0;
  }    

  LCDwhackDelay(_bitDelay*2); // if we were low this establishes the end

  // send ctrl-r to reset to 9600 baud?
}

// command functions

void LCDSerial::clearScreen(void) 
{
    putc( LCD_CMD );
    putc( LCD_CMD_CLEAR_SCREEN );
}

void LCDSerial::gotoLine(uint8_t line)
{
    putc( LCD_CMD );
    putc( (line) ? LCD_CMD_POS_LINE_TWO : LCD_CMD_POS_LINE_ONE);
}
void LCDSerial::gotoPos(uint8_t line, uint8_t pos)
{
    putc( LCD_CMD );
    putc( (pos + ((line) ? LCD_CMD_POS_LINE_TWO : LCD_CMD_POS_LINE_ONE)));
}

void LCDSerial::backlightOn(void)
{
    putc( LCD_BACKLIGHT );
    putc( LCD_BACKLIGHT_MAX );
}

void LCDSerial::backlightOff(void)
{
    putc( LCD_BACKLIGHT );
    putc( LCD_BACKLIGHT_MIN );
}

//
// the main method that does it all
//
void LCDSerial::print(uint8_t b)
{
  if (_baudRate == 0)
    return;
  byte mask;

  cli();  // turn off interrupts for a clean txmit

  digitalWrite(_transmitPin, LOW);  // startbit
  LCDwhackDelay(_bitDelay*2);

  for (mask = 0x01; mask; mask <<= 1) {
    if (b & mask){ // choose bit
      digitalWrite(_transmitPin,HIGH); // send 1
    }
    else{
      digitalWrite(_transmitPin,LOW); // send 1
    }
    LCDwhackDelay(_bitDelay*2);
  }
  
  digitalWrite(_transmitPin, HIGH);
  sei();  // turn interrupts back on. hooray!
  LCDwhackDelay(_bitDelay*2);
}

void LCDSerial::print(const char *s)
{
  while (*s)
    print(*s++);
}

void LCDSerial::print(char c)
{
  print((uint8_t) c);
}

void LCDSerial::print(int n)
{
  print((long) n);
}

void LCDSerial::print(unsigned int n)
{
  print((unsigned long) n);
}

void LCDSerial::print(long n)
{
  if (n < 0) {
    print('-');
    n = -n;
  }
  printNumber(n, 10);
}

void LCDSerial::print(unsigned long n)
{
  printNumber(n, 10);
}

void LCDSerial::print(long n, int base)
{
  if (base == 0)
    print((char) n);
  else if (base == 10)
    print(n);
  else
    printNumber(n, base);
}


// Private Methods ///////////////////////////////////////////////////////////

void LCDSerial::printNumber(unsigned long n, uint8_t base)
{
  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
  unsigned long i = 0;

  if (n == 0) {
    print('0');
    return;
  } 

  while (n > 0) {
    buf[i++] = n % base;
    n /= base;
  }

  for (; i > 0; i--)
    print((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10));
}
#ifndef _LCDSERIAL_H_
#define _LCDSERIAL_H_

#include <stdint.h>

// stolen from HardwareSerial.h
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0

class LCDSerial
{
  private:
    long _baudRate;
    uint8_t _transmitPin;
    void printNumber(unsigned long, uint8_t);

  public:
    LCDSerial(uint8_t lcdPin);
    void begin(long speed);
    void clearScreen(void);
    void gotoLine(uint8_t line);
    void gotoPos(uint8_t line, uint8_t pos);
    void backlightOn(void);
    void backlightOff(void);
    void print(char);
    void print(const char[]);
    void print(uint8_t);
    void print(int);
    void print(unsigned int);
    void print(long);
    void print(unsigned long);
    void print(long, int);
 };

#endif

The program was made in 2009, but I think it is outdated. But as I said, I got no experience in C++ so I can't update the program.

Could anyone help me update the program?

The first line in the errors is:

LCDSerial.cpp:30:24: error: WConstants.h: No such file or directory

I think you need to address this problem, and then see what errors remain?

Delta_G:
Go look in all the header files and see if you are including WProgram.h. If you are, change it to Arduino.h

If that is truly from 2009 then this change was made after that code and it is probably the source of your errors. It's always the first place I'm going to look if I see the built in constants coming back undeclared.

I am not including WProgram.h.

dannable:
The first line in the errors is:

LCDSerial.cpp:30:24: error: WConstants.h: No such file or directory

I think you need to address this problem, and then see what errors remain?

What do you mean by "address this problem"?

KastriotStefan:
What do you mean by "address this problem"?

Fix the problem.

The first error message is the first one you should fix.

It cannot find Wconstants.h, whatever that is.

You need to find out what that is, what needs it, and what it is called now.

KastriotStefan:

dannable:
The first line in the errors is:

LCDSerial.cpp:30:24: error: WConstants.h: No such file or directory

I think you need to address this problem, and then see what errors remain?

What do you mean by "address this problem"?

Edit the LCDSerial.cpp file at line 30. Replace #include "WConstants.h" with #include "Arduino.h"
See if that helps.

slomobile:

KastriotStefan:

dannable:
The first line in the errors is:

LCDSerial.cpp:30:24: error: WConstants.h: No such file or directory

I think you need to address this problem, and then see what errors remain?

What do you mean by "address this problem"?

Edit the LCDSerial.cpp file at line 30. Replace #include "WConstants.h" with #include "Arduino.h"
See if that helps.

Did that, but when I am trying to compile I get new errors..

In file included from WiiCoasterUI.cpp:44:
/wiichuck_funcs.h: In function 'void wiichuck_setpowerpins()':
wiichuck_funcs.h:59: error: 'PC3' was not declared in this scope
wiichuck_funcs.h:59: error: 'PC2' was not declared in this scope

Somehow I managed to update the program and there are no errors when I am compiling it. I uploaded the program to my microcontroller and "WiiCoasterUI" appears on the LCD screen, then it's stuck. It is supposed to show the amount of G-force and some other values too.

What is wrong?

Somehow I managed to update the program

But not post it again.

What is wrong?

There's a clue above...

PaulS:

Somehow I managed to update the program

But not post it again.

What is wrong?

There's a clue above...

Here's the updated version

#include <avr/interrupt.h>
#include "Arduino.h"

#include "LCDSerial.h"

#define LCD_CMD               ((uint8_t)0xFE)
#define LCD_CMD_CLEAR_SCREEN  ((uint8_t)0x01)
#define LCD_CMD_POS_LINE_ONE  ((uint8_t)128)
#define LCD_CMD_POS_LINE_TWO  ((uint8_t)192)

#define LCD_BACKLIGHT         ((uint8_t)0x7C)
#define LCD_BACKLIGHT_MIN     ((uint8_t)128)
#define LCD_BACKLIGHT_MAX     ((uint8_t)157)

#define putc(x) print((char)x)

static int _bitDelay;

#if (F_CPU == 16000000)
void LCDwhackDelay(uint16_t delay) { 
  uint8_t tmp=0;

  asm volatile("sbiw    %0, 0x01 \n\t"
	       "ldi %1, 0xFF \n\t"
	       "cpi %A0, 0xFF \n\t"
	       "cpc %B0, %1 \n\t"
	       "brne .-10 \n\t"
	       : "+r" (delay), "+a" (tmp)
	       : "0" (delay)
	       );
}
#endif


LCDSerial::LCDSerial(uint8_t transmitPin)
{
  _transmitPin = transmitPin;
  _baudRate = 0;
}

void LCDSerial::begin(long speed)
{
  pinMode(_transmitPin, OUTPUT);
  digitalWrite(_transmitPin, HIGH);

  _baudRate = speed;
  switch (_baudRate) {
  case 115200: // For xmit -only-!
    _bitDelay = 4; break;
  case 57600:
    _bitDelay = 14; break;
  case 38400:
    _bitDelay = 24; break;
  case 31250:
    _bitDelay = 31; break;
  case 19200:
    _bitDelay = 54; break;
  case 9600:
    _bitDelay = 113; break;
  case 4800:
    _bitDelay = 232; break;
  case 2400:
    _bitDelay = 470; break;
  default:
    _bitDelay = 0;
  }    

  LCDwhackDelay(_bitDelay*2); // if we were low this establishes the end

  // send ctrl-r to reset to 9600 baud?
}

// command functions

void LCDSerial::clearScreen(void) 
{
    putc( LCD_CMD );
    putc( LCD_CMD_CLEAR_SCREEN );
}

void LCDSerial::gotoLine(uint8_t line)
{
    putc( LCD_CMD );
    putc( (line) ? LCD_CMD_POS_LINE_TWO : LCD_CMD_POS_LINE_ONE);
}
void LCDSerial::gotoPos(uint8_t line, uint8_t pos)
{
    putc( LCD_CMD );
    putc( (pos + ((line) ? LCD_CMD_POS_LINE_TWO : LCD_CMD_POS_LINE_ONE)));
}

void LCDSerial::backlightOn(void)
{
    putc( LCD_BACKLIGHT );
    putc( LCD_BACKLIGHT_MAX );
}

void LCDSerial::backlightOff(void)
{
    putc( LCD_BACKLIGHT );
    putc( LCD_BACKLIGHT_MIN );
}

//
// the main method that does it all
//
void LCDSerial::print(uint8_t b)
{
  if (_baudRate == 0)
    return;
  byte mask;

  cli();  // turn off interrupts for a clean txmit

  digitalWrite(_transmitPin, LOW);  // startbit
  LCDwhackDelay(_bitDelay*2);

  for (mask = 0x01; mask; mask <<= 1) {
    if (b & mask){ // choose bit
      digitalWrite(_transmitPin,HIGH); // send 1
    }
    else{
      digitalWrite(_transmitPin,LOW); // send 1
    }
    LCDwhackDelay(_bitDelay*2);
  }
  
  digitalWrite(_transmitPin, HIGH);
  sei();  // turn interrupts back on. hooray!
  LCDwhackDelay(_bitDelay*2);
}

void LCDSerial::print(const char *s)
{
  while (*s)
    print(*s++);
}

void LCDSerial::print(char c)
{
  print((uint8_t) c);
}

void LCDSerial::print(int n)
{
  print((long) n);
}

void LCDSerial::print(unsigned int n)
{
  print((unsigned long) n);
}

void LCDSerial::print(long n)
{
  if (n < 0) {
    print('-');
    n = -n;
  }
  printNumber(n, 10);
}

void LCDSerial::print(unsigned long n)
{
  printNumber(n, 10);
}

void LCDSerial::print(long n, int base)
{
  if (base == 0)
    print((char) n);
  else if (base == 10)
    print(n);
  else
    printNumber(n, base);
}


// Private Methods ///////////////////////////////////////////////////////////

void LCDSerial::printNumber(unsigned long n, uint8_t base)
{
  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
  unsigned long i = 0;

  if (n == 0) {
    print('0');
    return;
  } 

  while (n > 0) {
    buf[i++] = n % base;
    n /= base;
  }

  for (; i > 0; i--)
    print((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10));
}

That's a library, not a sketch. Can you post your sketch too?

PeterH:
That's a library, not a sketch. Can you post your sketch too?

#define ledPin    13
#define lcdoutPin  7

#include "LCDSerial.h"

LCDSerial lcdSerial =  LCDSerial(lcdoutPin);

#include "wiichuck_funcs.h"

// sensor data in form:
// "|xxyyzz|xxyyzz|....\n"
// where 'xx','yy','zz'. are each a byte in ascii hex, 3-bytes per data payload
// terminated with newline
// every this many millisecs, read sensors, should be even mult of 1000
#define sensorUpdatesPerSec 10
#define sensorUpdateMillis (1000/sensorUpdatesPerSec)
#define SENSORBUFFSIZE (3*sensorUpdatesPerSec)

// overhead 
#define sensorUpdateMillisWFudge (sensorUpdateMillis - 10)

uint8_t sensorbuff[SENSORBUFFSIZE];
uint8_t sensorbuffidx;
uint8_t sensor_max[3];
uint8_t sensor_min[3];
uint8_t sensor_offsets[3] =   // zero-offsets, with initial guess
    {
        127,127,127
        //128,  // x
        //143,  // y
        //180   // z
    };
#define sensor_range 4   // wii nunchuck accelerometer is +/- 2g => 4g total
// see http://wiire.org/Chips/LIS3L02AL

#define BUFFSIZE 75
char buffer[BUFFSIZE];      // this is the double buffer
uint8_t bufferidx;

char timebuff[7] = "hhddss";

uint8_t i;
unsigned long lasttime;
unsigned long lastctrltime;
uint8_t disp_mode;   // 0 = rec/play, 1 = max, 2 = min, 3 = lat/ong
uint8_t rec_mode = 0;    // 1 = record, 0 = pause/stop
uint8_t key_down;
uint8_t display_gees = 0;

#define DISP_REC 0
#define DISP_MAX 1
#define DISP_MIN 2


void setup() 
{
    pinMode( ledPin, OUTPUT);
    digitalWrite( ledPin, HIGH);

    Serial.begin(4800);          // This goes to data logger
    Serial.println("WiiCoasterUI");

    lcdSerial.begin(9600);       // this goes to the LCD, don't change baud!
    lcdSerial.clearScreen();
    lcdSerial.print("WiiCoasterUI");

    wiichuck_setpowerpins();
    delay(100);
    wiichuck_begin();

    // initialize any data that needs to be specific values
    memset(sensor_max, 0, 3);
    memset(sensor_min, 255,3);

    delay(1000);
    digitalWrite( ledPin, LOW);
    lcdSerial.clearScreen();
}

// returns ascii hex nibble
static char toHex(uint8_t h)
{
    h &= 0xf;
    if( h < 10 ) 
        return (h + '0');
    return (h - 10 + 'A');
}

// take a signed number, format it as a string into buff
static void formatInt8(char* buff, int8_t v)
{
    buff[0] = (v>0) ? '+':'-';
    buff[1] = ((abs(v)/100) %10) + '0';
    buff[2] = ((abs(v)/10)  %10) + '0';
    buff[3] = ((abs(v)/1)   %10) + '0';
    buff[4] = 0;
}
// turn a signed float byte into a character string
// this likely has lots of bugs
void formatFloat8(char* buff, int8_t v, float range)
{
    buff[0] = (v>0) ? '+':'-';
    v = abs(v);
    float f = (v*range/127)/2;
    buff[1] = (int)f + '0';
    buff[2] = '.';
    buff[3] = ((int)(f*10) %10) + '0';
    buff[4] = 0;
}

// convert milliseconds to a hour/min/sec string
static void millisToTimeStr( char* buff, unsigned long millis )
{
    long secs = millis/1000;
    long mins = secs/60;
    int hours = mins/60;
    secs = secs % 60;
    mins = mins % 60;
    buff[0] = (hours/10)+ '0';  // hours tens
    buff[1] = (hours%10)+ '0';  // hours ones
    buff[2] = (mins/10) + '0';  // mins tens
    buff[3] = (mins%10) + '0';  // mins ones
    buff[4] = (secs/10) + '0';  // secs tens
    buff[5] = (secs%10) + '0';  // secs ones
    buff[6] = 0;
}

void loop()
{
    char c;

    digitalWrite(ledPin, LOW);
    
    unsigned long thistime = millis();
    // wait until it's the right time
    if( (thistime - lasttime) >= sensorUpdateMillisWFudge ) { 
        lasttime = thistime;
        digitalWrite(ledPin, HIGH); // turn off "good data" LED so it pulses
        
        // Acquire sensor readings
        wiichuck_get_data();
        for( i=0; i<3; i++ ) { // loop thru x,y,z parts
            uint8_t v = wiichuck_accelbuf[i];
            if( v > sensor_max[i] && v!=255 ) sensor_max[i] = v;
            if( v < sensor_min[i] && v!=0   ) sensor_min[i] = v;
        }

        // Save data
        memcpy(sensorbuff+sensorbuffidx, wiichuck_accelbuf, 3);
        sensorbuffidx += 3;
        if( sensorbuffidx == SENSORBUFFSIZE ) {
            sensorbuffidx = 0;  // just loop, what else we gonna do?
        }

        // Do UI Parsing
        if( wiichuck_cbutton() ) {      // C button == clear min/max
            memset(sensor_max, 0, 3);   // reset maxs to 0
            memset(sensor_min, 255,3);  // reset mins to 255
            display_gees = !display_gees;
            //for( i=0; i<3; i++ ) 
            //    sensor_offsets[i] = wiichuck_accelbuf[i];  // FIXME: wrong
        }

        if( wiichuck_zbutton() ) {      // Z button == stop/start recording
            key_down = 1;               // keydown is for debounce
        }
        if( !wiichuck_zbutton()  && key_down ) {
            rec_mode = !rec_mode;
            key_down = 0;
        }

        // pick display mode based on inputs
        if( wiichuck_joyy() > 0xA0 )         disp_mode = DISP_MAX;
        else if( wiichuck_joyy() < 0x40 )    disp_mode = DISP_MIN;
        else                                 disp_mode = DISP_REC;

        // move stick to the right changes readout style
        if( wiichuck_joyx() > 0xA0 ) 
            display_gees = !display_gees;

        // Write to LCD
        lcdSerial.gotoPos(0,0);  // line 1
        if( disp_mode == DISP_MAX )
            lcdSerial.print("Max");
        else if( disp_mode == DISP_MIN ) 
            lcdSerial.print("Min");
        else 
            lcdSerial.print( (rec_mode) ? "Rec":"Stp");

        lcdSerial.gotoPos(0,7);
        // if no time from controller
        if( thistime - lastctrltime > 5000 ) {
            millisToTimeStr( timebuff, thistime );
        } 
        
        // print out time
        lcdSerial.print( timebuff[0] );
        lcdSerial.print( timebuff[1] );
        lcdSerial.print( ':' );
        lcdSerial.print( timebuff[2] );
        lcdSerial.print( timebuff[3] );
        lcdSerial.print( ':' );
        lcdSerial.print( timebuff[4] );
        lcdSerial.print( timebuff[5] );
        
        lcdSerial.gotoPos(1,0); // line 2
        lcdSerial.print( (display_gees) ? "g:":"w:" );
        char buff[5];
        for( i=0; i<3; i++) {
            uint8_t v;
            if( disp_mode==DISP_MAX ) v = sensor_max[i];
            else if( disp_mode==DISP_MIN ) v = sensor_min[i];
            else v = wiichuck_accelbuf[i];
            if( display_gees ) {
                int8_t vo = v - sensor_offsets[i];
                formatFloat8( buff, vo, sensor_range ); // range is +/- 2g => 4
            } else { 
                formatInt8( buff, v - 127);
            }
            lcdSerial.print( buff );
            if(i!=2) lcdSerial.print(',');
        }
    }

    
    // Over serial, can ask for last 10 readings with 'sensor dump command'
    // get sensor dump commands from serial 
    int n = Serial.available();
    if( n > 6 ) {       // "s221359", 7 bytes 
        char c = Serial.read();
        if( c != 's' && c!='S' )  // command byte
            return;

        // do rest of parsing, for time
        for( i=0; i<6; i++ )
            timebuff[i] = Serial.read();
        delay(5); // this is needed or SoftSerial reading this will choke 
        Serial.print( (rec_mode) ? 'r':'s' );
        // fill buffer with text version of sensor data
        bufferidx = 0;
        for( i=0; i< sensorUpdatesPerSec; i++) {
            uint8_t si = (i*3);
            buffer[bufferidx+0] = '|';
            buffer[bufferidx+1] = toHex(sensorbuff[si+0]>>4);
            buffer[bufferidx+2] = toHex(sensorbuff[si+0]);
            buffer[bufferidx+3] = toHex(sensorbuff[si+1]>>4);
            buffer[bufferidx+4] = toHex(sensorbuff[si+1]);
            buffer[bufferidx+5] = toHex(sensorbuff[si+2]>>4);
            buffer[bufferidx+6] = toHex(sensorbuff[si+2]);
            bufferidx+=7;
        }
        buffer[bufferidx++] = '\r';
        buffer[bufferidx]   = '\n';
        buffer[bufferidx+1] = 0;
        
        Serial.print(buffer); // dump it out

        sensorbuffidx = 0;   // reset
        memset(sensorbuff, 0, sizeof(sensorbuff));

        lastctrltime = millis(); // say we saw a command
    }

}

I've found out that the program get stuck at line 65 of the main code.

lcdSerial.print("WiiCoasterUI");

The screen keep displaying "WiiCoasterUI" and nothing else happens.

When you say "The screen keep displaying" I assume you mean the LCD.

Do you also have output from Serial.println("WiiCoasterUI"); on the serial monitor?

Is your sketch actually completing setup()? Is loop() being called and completing OK? Is the code you expect to be called within loop() actually being called? Serial.print is your friend here. When you have an application which seems to be dead, start by finding out whether it's running at all and whether it's executing the parts of the code you expect it to.

That WConstants.h seems to be a problem often.

lcdSerial.print("WiiCoasterUI");

The screen keep displaying "WiiCoasterUI" and nothing else happens.

That is what that code is supposed to do, is it not ?

What else do you expect to happen ?

If WiiCoasterUI is actually some kind of variable name, and you want to display the value of the
variable, then you would write something more like

lcdSerial.print( WiiCoasterUI );

without the double quotes on it.