I’ve just purchased a neo-pixel strip. It works fine but I want to code it so it only turns on when the light level is low. Should be simple but I just cant get it to work. I’m usng the BBC microbit and this is a high school project . Any help would be appreciated.
No problem! We can definitely help you out with this! Could you please start by sharing a photo of how you have wired everything together, and the code that you are using?
You’ll need to use a sensor (such as a light dependant resistor (LDR) ) to check the ambient light level, and then make decisions on that.
The RGB strip by itself can’t sense light levels.
If you are using make code it is possible to use the LED Display on the microbit as a light sensor.
It is also possible in MicroPython.
light box.pdf (287.3 KB)
I cant seem to uplad the file. Can I email it to you?
I see the code now. What is the problem that you are having with it? What aspect isn’t working?
The lights come on when the program starts but if the light level increases to over 100 then they do not turn off. The problem seems to be in getting the “else” part of the program to work . “strip clear” does not seem to be the correct code. Any thoughts
It looks like the “else” part of the code clears the strip, but does not send that command to the strip. Add in a strip:show after the strip:clear and see if that works!