I'm trying to use (i), the sum of the sine values, as the basis for my if loop. The if loop needs to store the values of (d), for which sin(d*pi/180)+1 is equal to a fraction or multiple of (i), into the array arr. When I try to use i on the right side of the if statement, the code doesn't work properly, but if I try to constants, then the code works. I need a way to use variables, because I will not know ahead of time what I is going to be.
int arr[10];
//signed int d;
float i = 0;
int p;
float d;
float e;
//float s = sin(d*(PI/180))+1;//float produces decimals
void setup(){
Serial.begin(9600);
}
void loop(){
for(d = 0; d < 360; d++){
i = i + sin(d*(PI/180))+1;//add each value to the previous one
}
Serial.println(i/360);//print the average of the values
delay(500);
for(d = 0; d < 360; d++){
if (sin(d*(PI/180))+1 == 1.5*i/360){
arr[p++] = d;
}
}
for(p = 0; p < 10; p++){
Serial.println(arr[p]);
delay(500);
}
}