Hi everyone!
i just need some help finding the error, really bugging me out rn XD
The error code is:
"Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
valueFunction:8:3: error: expected unqualified-id before 'for'
for(int x = 0; x < 300; x++)
^~~
valueFunction:8:18: error: 'x' does not name a type
for(int x = 0; x < 300; x++)
^
valueFunction:8:27: error: 'x' does not name a type
for(int x = 0; x < 300; x++)
^
valueFunction:23:2: error: expected ';' after class definition
}
^
;
valueFunction:30:3: error: expected unqualified-id before 'private'
private:
^~~~~~~
C:\Users\jacklythgoe\Documents\Training\Arduino Projects\Elegoo\FrequencyAndPressureOnLCD\FreqProjectv2\valueFunction\valueFunction.ino: In function 'int freqToLevelConv(float)':
valueFunction:41:28: error: 'freqInHz' was not declared in this scope
int high = (sizeof(freqInHz) / sizeof(freqInHz[0])) - 1;
^~~~~~~~
valueFunction:44:16: error: expected primary-expression before ')' token
while(low<=)
^
valueFunction:52:13: error: 'iround' was not declared in this scope
p = iround(p);
^~~~~~
C:\Users\jacklythgoe\Documents\Training\Arduino Projects\Elegoo\FrequencyAndPressureOnLCD\FreqProjectv2\valueFunction\valueFunction.ino:52:13: note: suggested alternative: 'round'
p = iround(p);
^~~~~~
round
valueFunction:62:13: error: expected '}' before 'else'
else if (x > freqInHz[mid])
^~~~
C:\Users\jacklythgoe\Documents\Training\Arduino Projects\Elegoo\FrequencyAndPressureOnLCD\FreqProjectv2\valueFunction\valueFunction.ino: At global scope:
valueFunction:74:5: error: expected declaration before '}' token
}
^
exit status 1
expected unqualified-id before 'for'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences."
int x;
class FreqToLevelConv
{
public:
int index = 0;
for(int x = 0; x < 300; x++)
{
index++;
double varToPower4 = x * x * x * x;
double varToPower3 = x * x * x;
double varToPower2 = x * x;
double varToPower1 = x;
freqInHz[index] = -(0.0000000001 * varToPower4) +
(0.0000000928 * varToPower3) -
(0.0000243704 * varToPower2) -
(0.0261888889 * varToPower1) +
44.6760000001;
}
}
int getLevel(float frequency)
{
return freqToLevelConv(frequency);
}
private:
float iround (float num)
{
return (((int)(num * 100 + .5) / 100.0));
}
int freqToLevelConv(float x)
{
float p;
int low = 0;
int high = (sizeof(freqInHz) / sizeof(freqInHz[0])) - 1;
int mid = 0;
while(low<=)
{
mid = (low+high)/2;
if (x < freqInHz[mid])
{
p = ((x - freqInHz[mid]) < 0) ? -(x - freqInHz[mid]) : (x - freqInHz[mid]);
p = iround(p);
if (p <= 0.059999999)
{
return mid;
}
else
{
high = mid - 1;
}
else if (x > freqInHz[mid])
{
low = mid + 1;
}
else
{
return mid;
}
}
return -1;
}
}
}