Pattern Led PROBLEMS

Hi guys ! I have these scheme. The pattern works, but the problem is that the when one led is on the other one doesn’t go off. Can you please help me with that small problem?

The 1st problem is that you have 2 nodes controlling LED 1, and they both have ACT set to true, so LED 1 is going to be unstable.

The labels are too small to read; what is the difference between the 2 blocks of code for LED 1? Just the constants for delay and/or fade? You could eliminate the duplicate code if you use use select node(s) to feed those values.

Note that with current config, if it is time to turn off an LED, it will 1st finish its current fade cycle (which could be turning on), then it will start delay. When delay finishes, it will send pulse through branch-F and start the fade to 0, so it may take some time to turn off.

how should I use the select node?

I can’t see numbers in your patch, so I can’t work out your timing. If you are fading on, then immediately start fading off, using a sine-wave node would be much simpler than what you are doing here. If you want it to fade on, stay on a bit, then start fading off & stay off a bit, then sine-wave might not work for you (or you could “cheat” by multiplying sine-wave-OUT by say 2, then feed it to clip to restrict it to 0-1 values. This would cause you to get to full on in 1/4 the cycle time, stay on for 1/4, then fade to off over 1/4, then stay off 1/4; if you want different times for on & off, things get more complicated). sine-wave-EN would get condition output now feeding branch node; sine-wave-RST would get pulse-on-false of the same signal. The one sine-wave node can replace the 2 delay & defer nodes, fade, and branch. This will cause LED to immediately turn off when condition goes false. You still would not be able to have 2 LED1 nodes active at the same time, though.

I’m not certain, but I think replacing sine-wave with tri-wave will give you closer to what fade is currently doing (graph of tri-wave being a straight line from 0-1 and 1-0 instead of the curve generated by sine-wave).

The acting of the 2 leds is regulated by the distance sensor , here is how the project should work.

Your chart & program don’t match up since program has 2 rates for LED 1 & chart shows 2 rates for LED 2. I will program to your chart.

This uses tweak-number instead of range finder and watch instead of led so I could test using simulator. tri-wave provides blink for each LED. pulse-on-false resets tri-wave to 0 when it is disabled (so LED will be off rather than stay in its current state).

We can only have one LED on at a time because LED 1 is on when input is greater than 0.4 & LED 2 is on when that is NOT true.

2nd LED has 2 different blink rates, so we change tri-wave-T using nth-input. We kind of cheat on nth-input-IDX by using a boolean input. We can get away with this because false will translate to 0 and true will translate to 1.

Update: Just realized I got a little TOO fancy. If-else would be much better in place of nth-input. I started thinking select and realized nth-input was easier, but brain-fart kept me from realizing there are only 2 values, so if-else should be the obvious choice…

I used “if else”. The but the problem was not solved. Where do you think should I punt “if else”?

In my code? It replaces nth-input. In your code? You collapse the 2 sets of code for LED 1 and use it to feed delay-T instead of hard-coding it.

I try to use if else in your code. but when one led is on the other one should be off, but it doesn’t happens.

Is LED that is supposed to be off at full bright? Did you wire LED from pin to ground, or pin to V+? It will be full bright when set to LUM 0 if you wired to V+ instead of ground. If you switch LED from V+ to ground, you will need to flip it at the same time since it is a diode and only allows power to flow in one direction.

this is the scheme

Can’t see much of your wiring, but red LED connects from signal pin to V+, so it will be on when signal pin is off. You either need to wire the LEDs to ground, or rewrite your code to use LUM of 1 to turn off LEDs (which won’t be easy using tri-wave node). Move the resister from + bar to - bar and flip the LED and current code should work.