Hi! I would like to do a 2 blinking LEDs which are will be turn on & off by using a 1 button.
I don’t understand how to connect clock out TICK with led in LUM. In my mind I already know that TICK out is a pulse and LUM in is a number… please help me. Maybe I thinking wrong?
We need more information about how you actually want it to work. Does it just switch which LED is on when you push button? When does the blinking happen? What exactly happens when you push the button (switch which light is on? Start/Stop blinking of both LEDs? Start blinking the “other” LED?
If you just want to switch which LED is on, it can be as simple as this:
But in this scheme doesn’t turning off a LEDs when I push a button second time. As I understood the second flip-flop node toogle a last value from clock node out and remember them. Bases on this- in such moment when I push a button LEDs will be freeze ON when blink fires or OFF when not.
(repeat) I need to turn ON two blinkilng LEDs when push a button at first time. And turn them off when I push a button in second time.
Unfortunately, the suggestion above doesn’t help because setting led-ACT false only disables making updates to led, it doesn’t turn it off.
One option would be to run a new wire from button to flip-flop-RST at the bottom. This will turn led off each time the button is pushed, but they will start flashing if top flip-flop is now true.
At PRS add a “pulse-on-true” node, I have verified in other examples that sometimes it does not send a clean pulse if it connects directly to TGL, it could be a bug…
неа) Так же. У меня частота мигания раз в секунду. И если я нажму кнопку когда светодиоды горят - они так и зависнут горящими. у LED вход ACT я так понял отвечает за яркость.
YEEEES! It is works! I control a turn ON/OFF by one button! Thanks a lot!!!
May I ask you a question? - I think that a second flip-flop node is not a trivial decision. Does XOD have a buffer node which convert a pulse TICK out from clock to a number in of LED node?
You were told about this above, I just showed it with an example. You just did not understand in words how to organize this in the project. I’m the same newcomer as you, therefore I decided to show in the picture, since it’s not always clear to myself what to do when they explain without an example.
It depends what you want the pulse to do. If you want each pulse to increase the brightness of the LED, you could use count. If you want each pulse to turn the LED on/off, flip-flop-TGL is the most obvious solution.
To convert a pulse to a number, you can’t just do a direct conversation (like number to string, or Boolean to 0/1); you have to perform some action that defines what each pulse should do. Does the pulse add a set value to current number? Multiply a set value to current number? Reset count that is always running? Toggle on/off? The possibilities are endless… That is why there is no single way to make the conversion from pulse to number.
The example above using count instead of flip-flop will work, but is more complicated than just using flip-flop (as seralex noted); however, if you needed to rotate between 3 or more values instead of just 2, it now becomes the preferred solution.
The thing about programming is that one minor change in the requirements can often make a big difference in what the preferred solution will be. That is part of the reason it is so hard to help people when they just ask for a general solution with no example of what they are trying to do. There are often too many unanswered questions to be able to provide good help.
Just to show that there are often many “correct” solutions, the clock/flip-flop above is really just implementing a square-wave, so it could be simplified:
The True at the top is a tweak-boolean representing your button & the watch at the bottom represents the LED so I can test in simulation mode (simulation cannot simulate physical hardware like buttons & LEDs).
One advantage of this solution, is there are other wave nodes that could be used instead if you want the flashing to fade on/off.
I suppose if you wanted to, you could even use tri-wave and use the different steps of the wave to represent multiple values. There will be fewer nodes than using count with compare/defer nodes to reset, but it would be more convoluted/obfuscated (harder to understand what you are doing), and timing issues might cause rounding errors that cause specific values to get skipped sometimes.
Great stuff! It is such examples that are not enough in the description of the nodes. Sometimes it’s not clear what the node is for and how it can be used. Such examples perfectly reveal the understanding of the node and its application !!!