Im getting the error message "expected primary-token before ',' token" What do I do to fix it?

#include <LiquidCrystal.h>
LiquidCrystal lcd (12, 11, 10, 13, 3, 2);
int BUTTON_PIN = 4;
int buttonState = 0;

void setup() {
pinMode (LiquidCrystal, OUTPUT); **This is the line highlighted with the error message
pinMode (BUTTON_PIN, INPUT);

Serial.begin(9600);
}

void loop() {
buttonState = digitalRead (BUTTON_PIN);

Serial.println(buttonState);

if (buttonState == HIGH) {
lcd.begin (16, 2);
lcd.print ("Welcome!");
}
void loop () {
lcd.scrollDisplayLeft();
delay (1000);

}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

There are multiple problems with your sketch, not least that you have two loop() functions in it

Here is it formatted in the IDE using Auto Format to tidy up its presentation (but not its contents)

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 13, 3, 2);
int BUTTON_PIN = 4;
int buttonState = 0;

void setup()
{
    pinMode(LiquidCrystal, OUTPUT);
    pinMode(BUTTON_PIN, INPUT);

    Serial.begin(9600);
}

void loop()
{
    buttonState = digitalRead(BUTTON_PIN);

    Serial.println(buttonState);

    if (buttonState == HIGH)
    {
        lcd.begin(16, 2);
        lcd.print("Welcome!");
    }
    void loop()
    {
        lcd.scrollDisplayLeft();
        delay(1000);
    }

Note how the last closing brace is not on the left margin. That usually indicates that you do not have matched pairs of opening and closing braces in the sketch

2 Likes

Hi @vlopez04804 ,

Welcome to the forum..

pinMode is used for gpio pins not on a lcd screen..
move the lcd.begin up into setup replacing the pinMode on the lcd..
this will initialize the lcd and get it ready..
delete that last void loop{ line, not sure what that is about..

good luck.. ~q

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.