Motion sensor with random color light

Hi I’m just getting start with lighting. I want to make lighting circuit using motion sensor to turn on an LED but the hardest part that I cannot solve is that I want my LED changes the color every time motion sensor work. Like 1st time blue turn on and for 2nd time red turn on and repeat in a set. Is it possible to do something like this?

Thanks

Hi,
you could use a switch-case control structure

Every time motion is detected you could use a counter adding up
counter++;
then reset it when a max counter value has been reached.

If you need help about coding for a motion sensor I suggest this tutorial:

I'd advise learning about state machines - then you just have to draw out the
state-transition diagram for your LED logic and map this directly to code. The
state here presumably represents the last LED colour.

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