# 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,

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,

active| newest | oldestfloat 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 floatfloat vdc1;

float I04_C; //must be floatvoid 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 functionI04_C = constrain(I04_C, 20, 1000);

Serial.println(" I04_C = " + (String) I04_C);

delay (25);

}

Thank you for your support iceng.

it turns out I was trying to use a polynomial. and i was writing it the wrong way.

I followed the instructions below. : From: steveastrouk

The results is exactly as i needed.

your support is much appreciated.

Thanks again,

Steve,.

From: steveastrouk

Date: Sep 7, 2017. 5:47 PM

Subject: https://www.instructables.com/answers/Arduino-Error-expected-before-token/

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 floatfloat vdc1;float I04_C; //must be floatvoid 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); }

reply: https://www.instructables.com/you/backtalk/?action=reply&commentId=CUW4AHVJ7AQNH2Z

From: steveastrouk

Date: Sep 7, 2017. 5:53 PM

Subject: https://www.instructables.com/answers/Arduino-Error-expected-before-token/

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

reply: https://www.instructables.com/you/backtalk/?action=reply&commentId=C92DCYXJ7AQNH5U

,

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