Adafruit Smart RGB Neopixel live colour changes

Hi, I'm trying to change the colour of the Neopixel based on input from the VL53L0X distance sensor using simple if statements. For some reason it i not working. Is there a problem with my code? Or are the lights unable to do live colour updates?

nevermind I solved the problem :slight_smile:

I needed to put the pixels.show(); in each if statement

Good!

Before posting next time, please read and use this link, especially the part about posting code: How to get the best out of this forum - Using Arduino / IDE 1.x - Arduino Forum

Your code is flawed. It can never reach that last else if. If range is greater than 120 then it is also greater than 90 so the middle one will be the one that catches. If you want it to work then the middle if needs to also test that the range is less than 120.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.