expected initializer before '.' token

Hi there,

Trying to compile this "hello world" sketch from the arduino cookbook I get the message "expected initializer before '.' token".

I am newby in programming. Can somebody help me please?

/*
LiquidCrystal Library - Hello World
Demonstrates the use of a 16 × 2 LCD display.
*/

#include <LiquidCrystal.h> // include the library code

//constants for the number of rows and columns in the LCD
const int numRows = 2;
const int numCols = 16;

// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
LiquidCrystal lcd.init()
LiquidCrystal lcd.begin(numCols, numRows);
LiquidCrystal lcd.print("hello, world!"); // Print a message to the LCD. }
}

void loop()
{
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
LiquidCrystal lcd.setCursor(0, 1);
// print the number of seconds since reset:
LiquidCrystal lcd.print((millis) / 1000);
}

Expected code tag before "/*" token.

// initialize the library with the numbers of the interface pins 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.init();

etc

Does the code in the book really look like that?

@AWOL, I guess that's a bit cryptic :slight_smile:

@MD1951
What are all those LiquidCrystal 'things' doing in your setup and loop?

  LiquidCrystal lcd.init();

This would declare a variable of type LiquidCrystal called lcd.init() (if it would compile). Get rid of the LiquidCrystal.

You're also missing a semi colon at the end of that line.

Go back to the cookbook and compare your code with the code that the book presented. If it's the same, feed the cookbook to the dogs, else fix the code.

MD1951:
Hi there,

Trying to compile this "hello world" sketch from the arduino cookbook I get the message "expected initializer before '.' token".

I am newby in programming. Can somebody help me please?

/*
LiquidCrystal Library - Hello World
Demonstrates the use of a 16 × 2 LCD display.
*/

#include <LiquidCrystal.h> // include the library code

//constants for the number of rows and columns in the LCD
const int numRows = 2;
const int numCols = 16;

// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
LiquidCrystal lcd.init()
LiquidCrystal lcd.begin(numCols, numRows);
LiquidCrystal lcd.print("hello, world!"); // Print a message to the LCD. }
}

void loop()
{
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
LiquidCrystal lcd.setCursor(0, 1);
// print the number of seconds since reset:
LiquidCrystal lcd.print((millis) / 1000);
}

AWOL:
Expected code tag before "/*" token.

// initialize the library with the numbers of the interface pins 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.init();


etc


Does the code in the book really look like that?

AWOL:
Expected code tag before "/*" token.

// initialize the library with the numbers of the interface pins 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.init();


etc


Does the code in the book really look like that?

Is there a question ?