so, Ive mapped sensor data to an LED's PWM values. with doing this, the fading is far from smooth. I've tried the example smoothing, but I'm not seeing any positive results. any feedback, suggestions, resources very appreciated. heres a chunk of code:
int values = cm; //cm = the values from sensor
//forwrd fade
outputValue1 = map(values, 25, 39, 0, 255);
outputValue2 = map(values, 39, 25, 0, 255);
outputValue3 = map(values, 2, 24, 0, 255);
outputValue4= map(values, 24, 2, 0, 255);
// change the analog out value:
}
//analogWrite(led1, outputValue1);
// analogWrite(ledsignal, outputValue2);
if(values >= 25 ){
analogWrite(ledG1, outputValue1);
analogWrite(ledG2, outputValue1);
analogWrite(ledR1, outputValue2);
analogWrite(ledR2, outputValue2);
digitalWrite(ledY1, LOW);
digitalWrite(ledY2, LOW);
}
if(values >= 2 && values <= 24)
{
analogWrite(ledY1, outputValue4);
analogWrite(ledY2, outputValue4);
analogWrite(ledR1, outputValue3);
analogWrite(ledR2, outputValue3);
digitalWrite(ledG1, LOW);
digitalWrite(ledG2, LOW);