Go Down

Topic: Expected unqualified-id? (Read 642 times) previous topic - next topic

adam1997gipe

I don't know where to find some of these errors. I'm getting errors stating it's looking for a semi-colon, but when I put one exactly where it says it wants one, I get a different error about not being able to resolve address or function. Will someone please tell me what I'm doing wrong? I'm really new to programming and the rest of the internet is not helping me understand my errors. I'm creating an optical tachometer using an IR emitter and detector I bought from radioshack

Code: [Select]

#include <LiquidCrystal.h>

LiquidCrystal 8, 10, 9;   // DEFINE LCD PINS

volatile byte REV;       //  VOLATILE DATA TYPE TO STORE REVOLUTIONS
 
unsigned long int rpm, maxRPM;  //  DEFINE RPM AND MAXIMUM RPM
 
unsigned long time;         //  DEFINE TIME TAKEN TO COVER ONE REVOLUTION
 
int ledPin = 12;           //   STATUS LED
 
int led = 0,RPMlen , prevRPM;  //  INTEGERS TO STORE LED VALUE AND CURRENT RPM AND PREVIOUS RPM
 
int flag = 0;             //  A VARIABLE TO DETERMINE WHETHER THE LCD NEEDS TO BE CLEARED OR NOT

long prevtime = 0;       //  STORE IDLE TIME TO TOGGLE MENU
   
 void setup()
 {
     Serial.begin 9600  // GET VALUES USING SERIAL MONITOR
     
     LiquidCrystal.begin 16, 2;     // INITIATE LCD
     
     attachInterrupt(0, RPMCount, RISING);     //  ADD A HIGH PRIORITY ACTION ( AN INTERRUPT)  WHEN THE SENSOR GOES FROM LOW TO HIGH
     
     REV = 0;      //  START ALL THE VARIABLES FROM 0
     
     rpm = 0;
     
     time = 0;
     
     pinMode ledPin, OUTPUT;
     
     pinMode 3, OUTPUT;           
     
     pinMode 4, OUTPUT;
     
     digitalWrite(3, HIGH);             //  VCC PIN FOR SENSOR
     
     digitalWrite(4, LOW);              // GND PIN FOR SENSOR
     
     LiquidCrystal.print("TACHOMETER");           //   STARTUP TEXT
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print("- Adam Gipe");      //  THAT'S ME
     
     delay(2000);
     
     LiquidCrystal.clear();
     
 }
 
 void loop()
 {
  long currtime = millis();                 // GET CURRENT TIME
 
  long idletime = currtime - prevtime;        //  CALCULATE IDLE TIME
   
    if(REV >= 5 )                  //  IT WILL UPDATE AFETR EVERY 5 READINGS
   {
     
             
     if(flag==0)                     //  CLEAR THE LCD TO AVOID ANY GARBAGE TEXT
     {
       LiquidCrystal.clear();
       
       LiquidCrystal.print("SENSOR MEASURING");
       
       flag=1;                          //   AFTER FLAG = 1 , THE LOOP WILL NOT EXECUTE AGAIN
     }
     
     rpm = 30*1000/(millis() - time)*REV;       //  CALCULATE  RPM USING REVOLUTIONS AND ELAPSED TIME
     
     if(rpm > maxRPM)
     
     maxRPM = rpm;                             //  GET THE MAX RPM THROUGHOUT THE RUN
   
     time = millis();                           
     
     REV = 0;
     
     int x= rpm;   
     //  CALCULATE NUMBER OF DIGITS IN RPM
     while(x!=0)
     {
       x = x/10;
       
       RPMlen++;
     }       
         
     
     
     if(RPMlen!=prevRPM)                             // IF THE RPM FALLS TO A LOWER NUMBER WITH LESS DIGITS , THE LCD WILL GET CLEARED
     {
       LiquidCrystal.clear();
       
       prevRPM = RPMlen;
       
       flag=0;
       
       LiquidCrystal.print("SENSOR MEASURING");
     }
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print(rpm,DEC);                        //  PRINT RPM IN DECIMAL SYSTEM
     
     LiquidCrystal.setCursor(6,1);
     
     LiquidCrystal.print("RPM");
     
     delay(500);
     
     prevtime = currtime;                        // RESET IDLETIME
   
   }
   
   if(idletime > 5000 )                      //  IF THERE ARE NO READING FOR 5 SEC , THE SCREEN WILL SHOW MAX RPM
   {
     
     if(flag==1)                            // CLEAR THE LCD
     {
       LiquidCrystal.clear();
       flag=0;
     }
     
     LiquidCrystal.clear();
     
     LiquidCrystal.print("MAXIMUM RPM");
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print(maxRPM,DEC);         // DISPLAY MAX RPM
     
     LiquidCrystal.print("   RPM");
     
     delay(2000);
     
     LiquidCrystal.clear();
     
     LiquidCrystal.print("IDLE STATE");
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print("READY TO MEASURE");
     
     delay(2000);
     
     prevtime = currtime;
   }
     
 }
 
 void RPMCount()                                // EVERYTIME WHEN THE SENSOR GOES FROM LOW TO HIGH , THIS FUNCTION WILL BE INVOKED
 {
   REV++;                                         // INCREASE REVOLUTIONS
   
   if (led == LOW)
   {
     
     led = HIGH;                                 //  TOGGLE STATUS LED
   }
   
   else
   {
     led = LOW;
   }
   digitalWrite(ledPin, led);
 }

RayLivingston

The first number, after the first colon, is the line where the error was found.  The second number is the character on that line.  The error message tells you EXACTLY where each error is.

Regards,
Ray L.

PaulS

Code: [Select]
     Serial.begin 9600  // GET VALUES USING SERIAL MONITOR
Missing something? More than one thing, actually. Three, to be precise.
The art of getting good answers lies in asking good questions.

adam1997gipe

I know that, what i'm trying to say is I don't see the error the software is telling me I made. One code said that I was missing a semi colon before the numeric constant. I put that semi colon right where it said it wanted one and i get a different error about the address and function. I don't understand how to fix the errors its saying I have, but I figured out where they were

CrossRoads

Serial.begin (9600);

You could always check the Reference page for proper syntax of commands.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

This line
LiquidCrystal 8, 10, 9;   // DEFINE LCD PINS
You need to look up the proper syntax in the LiquidCrystal library.
Could be as simple as
LiquidCrystal (8, 10, 9);   // DEFINE LCD PINS
I don't have the library, so I can't say more.

unsigned long int rpm, maxRPM;  //  DEFINE RPM AND MAXIMUM RPM
Can you do both in one line? I never tried, make them separate lines.

int led = 0,RPMlen , prevRPM;
One variable name, trying to give it 3 values?

A lot of your errors are just syntax. Fix them.



Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

adam1997gipe

That is what confused me. Online is says to have lcd.begin(cols, rows). When I type that it says that LCD was not declared, so I substitute LiquidCrystal in for lcd becuase I added the LiquidCrystal library. I have it LiquidCrystal.begin(16, 2) and it says its expected unqualified-id before '.' token. I don't know what I need to subsititute in before .begin.

adam1997gipe

I have the same error for every line i have LiquidCrystal.begin/print. The references page says it should be lcd.xxxxx but how would I declare LCD?

AWOL

#8
Mar 08, 2015, 08:39 pm Last Edit: Mar 08, 2015, 08:40 pm by AWOL
Post code

adam1997gipe

Code: [Select]

#include <LiquidCrystal.h>

//LiquidCrystal(8, 10, 9);   // DEFINE LCD PINS

volatile byte REV;       //  VOLATILE DATA TYPE TO STORE REVOLUTIONS
 
unsigned long int rpm;
unsigned long int maxRPM;  //  DEFINE RPM AND MAXIMUM RPM
 
unsigned long time;         //  DEFINE TIME TAKEN TO COVER ONE REVOLUTION
 
int ledPin = 12;           //   STATUS LED
 
int led = 0,RPMlen , prevRPM;  //  INTEGERS TO STORE LED VALUE AND CURRENT RPM AND PREVIOUS RPM
 
int flag = 0;             //  A VARIABLE TO DETERMINE WHETHER THE LCD NEEDS TO BE CLEARED OR NOT

long prevtime = 0;       //  STORE IDLE TIME TO TOGGLE MENU
   
 void setup()
 {
     Serial.begin (9600);  // GET VALUES USING SERIAL MONITOR
     
     LiquidCrystal.begin(16, 2)     // INITIATE LCD
     
     attachInterrupt(0, RPMCount, RISING);     //  ADD A HIGH PRIORITY ACTION ( AN INTERRUPT)  WHEN THE SENSOR GOES FROM LOW TO HIGH
     
     REV = 0;      //  START ALL THE VARIABLES FROM 0
     
     rpm = 0;
     
     time = 0;
     
     pinMode; ledPin, OUTPUT;
     
     pinMode ;3, OUTPUT;           
     
     pinMode ;4, OUTPUT;
     
     digitalWrite(3, HIGH);             //  VCC PIN FOR SENSOR
     
     digitalWrite(4, LOW);              // GND PIN FOR SENSOR
     
     LiquidCrystal.print("TACHOMETER");           //   STARTUP TEXT
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print("- Adam Gipe");      //  THAT'S ME
     
     delay(2000);
     
     LiquidCrystal.clear();
     
 }
 
 void loop()
 {
  long currtime = millis();                 // GET CURRENT TIME
 
  long idletime = currtime - prevtime;        //  CALCULATE IDLE TIME
   
    if(REV >= 5 )                  //  IT WILL UPDATE AFETR EVERY 5 READINGS
   {
     
             
     if(flag==0)                     //  CLEAR THE LCD TO AVOID ANY GARBAGE TEXT
     {
       LiquidCrystal.clear();
       
       LiquidCrystal.print("SENSOR MEASURING");
       
       flag=1;                          //   AFTER FLAG = 1 , THE LOOP WILL NOT EXECUTE AGAIN
     }
     
     rpm = 30*1000/(millis() - time)*REV;       //  CALCULATE  RPM USING REVOLUTIONS AND ELAPSED TIME
     
     if(rpm > maxRPM)
     
     maxRPM = rpm;                             //  GET THE MAX RPM THROUGHOUT THE RUN
   
     time = millis();                           
     
     REV = 0;
     
     int x= rpm;   
     //  CALCULATE NUMBER OF DIGITS IN RPM
     while(x!=0)
     {
       x = x/10;
       
       RPMlen++;
     }       
         
     
     
     if(RPMlen!=prevRPM)                             // IF THE RPM FALLS TO A LOWER NUMBER WITH LESS DIGITS , THE LCD WILL GET CLEARED
     {
       LiquidCrystal.clear();
       
       prevRPM = RPMlen;
       
       flag=0;
       
       LiquidCrystal.print("SENSOR MEASURING");
     }
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print(rpm,DEC);                        //  PRINT RPM IN DECIMAL SYSTEM
     
     LiquidCrystal.setCursor(6,1);
     
     LiquidCrystal.print("RPM");
     
     delay(500);
     
     prevtime = currtime;                        // RESET IDLETIME
   
   }
   
   if(idletime > 5000 )                      //  IF THERE ARE NO READING FOR 5 SEC , THE SCREEN WILL SHOW MAX RPM
   {
     
     if(flag==1)                            // CLEAR THE LCD
     {
       LiquidCrystal.clear();
       flag=0;
     }
     
     LiquidCrystal.clear();
     
     LiquidCrystal.print("MAXIMUM RPM");
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print(maxRPM,DEC);         // DISPLAY MAX RPM
     
     LiquidCrystal.print("   RPM");
     
     delay(2000);
     
     LiquidCrystal.clear();
     
     LiquidCrystal.print("IDLE STATE");
     
     LiquidCrystal.setCursor(0, 1);
     
     LiquidCrystal.print("READY TO MEASURE");
     
     delay(2000);
     
     prevtime = currtime;
   }
     
 }
 
 void RPMCount()                                // EVERYTIME WHEN THE SENSOR GOES FROM LOW TO HIGH , THIS FUNCTION WILL BE INVOKED
 {
   REV++;                                         // INCREASE REVOLUTIONS
   
   if (led == LOW)
   {
     
     led = HIGH;                                 //  TOGGLE STATUS LED
   }
   
   else
   {
     led = LOW;
   }
   digitalWrite(ledPin, led);
 }

adam1997gipe

Every line of code for the LCD gives me the same error, expected unqualified-id before '.' token. Online says I should have lcd.etc instead of LiquidCrystal.etc but it tells me lcd is not declared

christop

Then you need to declare lcd. Look at the example at http://arduino.cc/en/Reference/LiquidCrystalConstructor.

PaulS

Code: [Select]
//LiquidCrystal(8, 10, 9);   // DEFINE LCD PINS
If you are going to put stupid comments, you should make sure that they are correct. That one is NOT. That line is SUPPOSED to do much more than that. Go look at the examples in the LiquidCrystal library.
The art of getting good answers lies in asking good questions.

AWOL

Quote
Every line of code for the LCD
Did you mean "every line that has the class name, not an instance of the class, has an error"?

(There was a hint there)

RayLivingston

Code: [Select]

unsigned long int rpm;
unsigned long int maxRPM;  //  DEFINE RPM AND MAXIMUM RPM


I'm really curious what RPM you're measuring that requires an unsigned long to contain the number?  You really expect to see more than 65,535 RPM?  And how are you measuring that on an Arduino?

Regards,
Ray L.

Go Up