Expected unqualified-id before '.' token but why/where[SOLVED]

Whole day I am getting this error on lines 76&77. these are the message lines:
C:\Users\Harry\Documents\Arduino\2022\sketch_jan11b_xtrack\sketch_jan11b_xtrack.ino: In function 'void loop()':
sketch_jan11b_xtrack:76:16: error: expected unqualified-id before '.' token
HCPCA9685.Servo(SERVO_X, newXval);
^
sketch_jan11b_xtrack:77:16: error: expected unqualified-id before '.' token
HCPCA9685.Servo(SERVO_Y, newYval);
^
Allready reinstalled the used libraries. Could anyone tell what I missed here??

#include <HCPCA9685.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define LCD_ROWS  2
#define LCD_COLS  16
#define I2C_ADR 0x40

void setup() {
  Serial.begin(9600);
  lcd.begin(LCD_COLS, LCD_ROWS);
  lcd.clear();
  lcd.print("XtrackTerm V0.0f");
  delay(2000);
  lcd.clear();
  HCPCA9685 HCPCA9685(I2C_ADR);
  /* Wake the device up */
  HCPCA9685.Sleep(false);
  //  lcd.setCursor(0, 1);
  lcd.print("Waiting for data");
  Serial.println(">>initialized");
}
// Where receiving a string like 123.45,123.67\n
const int MAX_LEN = 14; // the max digits in the number plus decimal point
char  strInput[MAX_LEN + 1]; // add one for the terminating null
char  *strXval;    // ASCII X axis
char  *strYval;    // ASCII Y axis
int SERVO_X = 2;   // Servo X-axis
int SERVO_Y = 3;   // Servo Y-axis
int str_Index = 0; // conter for receiving string characters
int s = millis() / 1000;
float newXval = atof(strXval);
float newYval = atof(strYval);

void loop() {
  //Check to see if anything is available in the serial receive buffer
  while (Serial.available() > 0)
  {
    static char strValue[MAX_LEN];  //  hold the incoming message
    char inByte = Serial.read();  //Read the next available byte
    //Message coming in (check not terminating character) and guard for over message size
    if ( inByte != '\n' && (str_Index < MAX_LEN - 1) )
    {
      lcd.print("Receiving data  ");
      //Add the incoming byte to our message
      strValue[str_Index++] = inByte;
    } // end if
    //Full message received...
    else
    {
      //Add null character to string
      strValue[str_Index] = '\0';

/*  ===== Print the message (or do other things) === */
      //Serial.println(strValue);
      lcd.clear();
      lcd.println(" Data Received  ");
      strValue[str_Index] = 0;
      //Serial.println(strValue);
 /*  ===== Create the X and Y valueu from received messGE ===== */
      strXval = strtok(strValue, ",");
      strYval = strtok(NULL, ",");
      //Serial.print("X-Axix value = "); Serial.println(strXval);
      //Serial.print("Y-Axix value = "); Serial.println(strYval);
/*  ===== Update LCD screen row=1 ===== */
      lcd.setCursor(0, 1);
      lcd.print("X=");
      lcd.print(strXval);
      lcd.setCursor(8, 1);
      lcd.print("Y=");
      lcd.print(strYval);
/* ===== Reset for the next message =====  */
      str_Index = 0;
      strValue[str_Index] = "\0";
/* ======================================  */
      //updateServo();
//      HCPCA9685.Servo(SERVO_X, newXval);
//      HCPCA9685.Servo(SERVO_Y, newYval);
    } // end else
  } // end while
}// end loop()
  HCPCA9685 HCPCA9685(I2C_ADR);

Try giving the HCPCA9685 object a different name name than the library, but remember to change all instances of it throughout the sketch to the new name

This tells you the error in on line 76 of your code and was discovered 16 characters from the left end.
So, look at your code for line 76 and see what is possible wrong. We cant see your line numbers.

When you have fixed the problem @UKHeliBob pointed out, move the renamed object declaration up out of setup so it is global.

Good spot Bill !

Remove this line out of Setup
HCPCA9685 HCPCA9685(I2C_ADR);
Instead put it in the global declarations
e.g. just beneath
#define I2C_ADR 0x40

Also put this line at the top of your Setup function
HCPCA9685.Init(SERVO_MODE);

Finaly, try to recompile and load_up the sketch.

Following your suggestion I moved the line outside setup

#define I2C_ADR 0x40
  HCPCA9685 HCPCA9685(I2C_ADR);

The errorlines where these:[code]
HCPCA9685.Servo(SERVO_X, newXval);
HCPCA9685.Servo(SERVO_Y, newYval);

[/code]
THe code now compiles correct, thanks all
Harry

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