Constraining sensor values question… I’ve got a sensor giving me data, and want to use that data to control the brightness of my neopixels. So far so good.
I’m having trouble when the sensor numbers get too low or too high – the LEDs don’t just stay “off” if the numbers end up below 0, or stay “full bright” if the numbers go above 255. Here’s how I’ve tried to fix this… I think I’m doing it wrong. What’s a better way to constrain my post-calculated sensor values into 0-255?
proxbrightness = 255-(SENSORDATA*10);
if (proxbrightness < 1){
proxbrightness=1;
}
else if (proxbrightness > 250){
proxbrightness=250;
}
FastLED.setBrightness(proxbrightness);
Thanks!!