Go Down

Topic: Error: Expected primary-expression before ',' token (Read 9025 times) previous topic - next topic

luqmansss_

hello there. Im currently working on my university project. Im working on a smart traffic light that can indicate the traffic. Right now im stucked on the coding and i cant seem to understand the error. Help me pls :(

here is the code where there is an error
Code: [Select]

void set3()
{
  lcd.setCursor(colx, 0);
  lcd.print("NA ");
  lcd.setCursor(colx, 1);
  lcd.print("OK!!");
}


here is the error
Code: [Select]

error: expected primary-expression before ',' token

   lcd.setCursor(colx, 0);

                     ^

jajel:73: error: expected primary-expression before ',' token

   lcd.setCursor(colx, 1);

sterretje

Your error is more than likely caused by some code that you have not shown. Please provide your complete code.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

luqmansss_

sorry for that. here is my full code
Code: [Select]

#define colx
#include <LiquidCrystal.h>

int inputPin1 = 9;              //choose the input pin (for PIR1 sensor)
int inputPin = 8;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int sensor1, sensor2;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int val = 0;                    // variable for reading the pin status
int val1 = 0;

void setup() {
  pinMode(sensor1, INPUT);
  pinMode(sensor2, INPUT);
  lcd.begin (16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Sensor1:");
  lcd.setCursor(0, 1);
  lcd.print("Sensor2:");
}

void set1()
{
  lcd.setCursor(colx, 0);
  lcd.print("OK!!");
  lcd.setCursor(colx, 1);
  lcd.print("OK!!");
}
void set2()
{
  lcd.setCursor(colx, 0);
  lcd.print("OK!!");
  lcd.setCursor(colx, 1);
  lcd.print("NA ");
}
void set3()
{
  lcd.setCursor(colx, 0);
  lcd.print("NA ");
  lcd.setCursor(colx, 1);
  lcd.print("OK!!");
}
void default()
{
  lcd.setCursor(colx, 0);
  lcd.print("NA ");
  lcd.setCursor(colx, 1);
  lcd.print("NA ");
}

void set1()
{
  lcd.setCursor(colx, 0);
  lcd.print("OK!!");
  lcd.setCursor(colx, 1);
  lcd.print("OK!!");
}
void set2()
{
  lcd.setCursor(colx, 0);
  lcd.print("OK!!");
  lcd.setCursor(colx, 1);
  lcd.print("NA ");
}
void set3()
{
  lcd.setCursor(colx, 0);
  lcd.print("NA ");
  lcd.setCursor(colx, 1);
  lcd.print("OK!!");
}
void default()
{
  lcd.setCursor(colx, 0);
  lcd.print("NA ");
  lcd.setCursor(colx, 1);
  lcd.print("NA ");
}

void loop()
{
  int senread1 = digitalRead(sensor1);
  int senread2 = digitalRead(sensor2);

  if (senread1 == HIGH && senread2 == HIGH )
  {
    set1();
  }
  else if (senread1 == !HIGH && senread2 == HIGH )
  {
    set2();
  }
  else if (senread1 == HIGH && senread2 == !HIGH )
  {
    set3();
  }
  else
  {
    default();
  }

  delay(1);
}

Delta_G

Code: [Select]
#define colx

You've defined colx as nothing.  #define things get replaces before compilation.  So that line when the compiler sees it looks like

Code: [Select]
lcd.setCursor( , 0);

And now you see the error
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

luqmansss_

Code: [Select]
#define colx

You've defined colx as nothing.  #define things get replaces before compilation.  So that line when the compiler sees it looks like

Code: [Select]
lcd.setCursor( , 0);

And now you see the error
YOU ARE MY HERO MAN. That did the trick. Thank you thank you thank you thank you

spycatcher2k

Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

Go Up