Arduino Error expected ',' before '*' token?

My Sketch

I used Micro soft to generate the Polynomial  below.
    
 y = 28.089x5 - 158.77x4 + 410.33x3 - 426.65x2 + 532.31x - 320.03R² = 1

float I04 = A0;
int readValue1;
float x5 = 22.52;
float x4 = 95.802;
float x3 = 237.57;
float x2 = 126.81;
float x1 = 561.04;
float x0 = 448.98;
float I04_F = 0;
int vdc1;
int I04_C = 0;




void setup() {
  Serial.begin(9600);
  pinMode(I04, INPUT);
}

void loop() {

  { readValue1 = analogRead(I04);
    vdc1 = (5. / 1023.) * readValue1;
    I04_C = [x5 * vdc1 ^ 5] - [x4 * vdc1 ^ 4] + [x3 * vdc1 ^ 3] - [x2 * vdc1 ^ 2] + [x1 * vdc1] - x0;
    I04_C = constrain(I04_C, 20, 1000);
    Serial.println(" I04_C = " + (String) I04_C);
    delay (25);
  }

After compiling i get the following, Arduino Error    expected ',' before '*' token?

Thanks Steve,

float x5 = 22.52;
float x4 = 95.802;
float x3 = 237.57;
float x2 = 126.81;
float x1 = 561.04;
float x0 = 448.98;
float I04_F; //must be float
float vdc1;
float I04_C; //must be float




void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
}

void loop() {
vdc1 = (5 / 1023) * analogRead(A0); //Don't create needless variables)
I04_C = (x5*pow(vdc1,5)) - (x4*pow(vdc1,4)) + (x3 * pow(vdc1,3)) - (x2 * pow(vdc1,2)) + (x1 * vdc1) - x0;

//there is no ^ function in Arduino, you have to use the pow function


I04_C = constrain(I04_C, 20, 1000);
Serial.println(" I04_C = " + (String) I04_C);
delay (25);
}

StevenM267 (author) 11 days ago

Hello Steve,

Thank You very Much!

Great advice.

Much Appreciated.

Steve,.

Also don't constantly calculate 5/1023. Its a constant. Your program will run faster if you make it a constant.

Here'

float x5 = 22.52;
float x4 = 95.802;
float x3 = 237.57;
float x2 = 126.81;
float x1 = 561.04;
float x0 = 448.98;

NONE of these are constants, they are variables with initial values. When time and space are short, this is a bad thing