to geht the Index of my Array with max value and other users confirmd, that this example will do ist.
But if I use it in my code:
int ls[3]={0};
int getIndexOfMaximumValue(int* array, int size){
int maxIndex = 0;
int max = array[maxIndex];
for (int i=1; i<size; i++)
{
if (max<array) <---- Error in this Line ISO C++ forbids comparison between pointer and integer
{
max = array;
maxIndex = i;
}
}
return maxIndex;
}
void setup()
{}
void loop()
{
ls[0] = analogRead(A0);
ls[1] = analogRead(A1);
ls[2] = analogRead(A2);
ls[4] = analogRead(A3);
int a=getIndexOfMaximumValue(ls,4);
}
It says ISO C++ forbids comparison between pointer and integer...
I still have problems using pointers.
Thanks a lot for your help!
Of course you are right, The Array was too small. Ich changed it.
Thanks everybody for help, I havent seen the tiny [ i ] in wildbill´s Post. Now everything works fine!
I´m tyring to kalibrate some Phototransistors, to follow an light soure. First results:
There are 4 (should be 6 but only had 4) in a hexagonal box, arranged concentric and each of it is shielded to the others.
After I found the Index with the brightest Sensor (that was the reason for my question above) and a second if loop if the right or left one is brighter, I get the angle to 30°... After that I will do a calibration with Gauss squares error method. I hope to get the angle of my "lightsource" within a error of a few degrees... ( I did that with once with a Multi-hole probe for wind cancels)
Turn your face to the sun, the shadows will fall behind you.... kind of working title.