Help with the light module and rainbow


#1

Been playing around with my mega chest again and trying to get it so when it’s daylight the rainbow led’s are off and when it gets dark, they come on.
Is this possible? I have tried but all I can figure out is when it’s daylight the leds are on and when it gets dark the leds go off, completely the opposite from what I want.


#2

Hi there oaklandm,
I don’t actually have any Flotilla kit, but from looking at the Python API, could you not just us something along the lines of this? For instance;

brightness = module.light
if brightness > [LIGHT NUMBER]: #[LIGHT NUMBER] being the value of daylight
    [Set the rainbow module to off] #If it is light, turn the rainbow module on
else:
    [Set the rainbow module to on] #If it isn't light, turn on

As far as I can tell from the example files, the module.light function gives you some sort of numerical value rather than just True or False, so that should work. In theory at least…


#3

Thanks, I’ll have a look at it. I was only using rockpool as I have no idea about programming but will have a look at your example and see what I can figure out


#4

If you’d like to get into programming, Python is probably the best place to start! Don’t hesitate to ask if you need any assistance with it; it can certainly be daunting at first. :)


#5

@oaklandm if you figured out how to do the opposite of what you want, it should be as simple as inserting and inverting filter in rockpool between your input and your output.


#6

Yep. Basically what Rogue said.

The most basic way to do it is to add an invert modifier, as below.

If you want it to be a bit more sensitive, then you could add a couple of double modifiers too.

Or, finally, an alternative way to do it, where you can tweak the threshold and have it latch on and off, is to use a less than modifier and set the threshold to whatever your chosen level is.

Hope that helps!


#7

Thanks very much, works like a dream.


#8

Thanks for the advices.