for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
The compiler has already set the elements in readings to 0.
printArray(rangevalue, arraysize);
Why? You know what values are in the array at this point.
readings[index] = analogRead(anPin);
<snip>
pinMode(anPin, INPUT);
You set the pin to INPUT after you've read from it. Why? The pin mode should be declared in setup(), not loop(). In any case, this is wrong. The pinMode() function is for digital pins. So, you just set the mode for digital pin 1 (a serial pin, specifically the TX pin) to input. Bad idea.
if ( vals >= 212 && vals<=240 ){
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(ledsignal, HIGH);
}
I
love
code
that
wanders
across
the
page
for
no
reason.
vals = rangevalue[midpoint];
vals is a scalar. Why is the name plural? A more meaningful name would be useful.
The variable vals is used and then computed. Why is that?
but when i try this with my if statement, the mapping from sensor is causing confliction and in turn, causing the crossfade LEDS to flicker. suggestions?
What does "causing confliction" mean?
You are turning the fading LEDs off, but then on the next pass though loop, you resume them fading, and then turn them off again. It's no wonder they don't stay off.
if(vals >= 212 && vals<=240)
{
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(ledsignal, HIGH);
}
else
{
analogWrite(led1, outputValue1); // <-- move the analog writes to here
analogWrite(led2, outputValue2);
digitalWrite(ledsignal, LOW);
}
would work better.