Flip flop toggeling

hi,
i was following this video


but i didnt understand how he uses the toggle in flip flop to make the led once on once off with one button, in the info its said toggle converts the stored value, this means if the input 1 makes 0 and if 0 makes it 1…but how is this used to make the output always 1 when press the button then always off when press the button again ?
2 Likes

Have you gone through the built-in tutorial? 010-flip-flop shows an example for using flip-flop. If you want to control an LED, replace the watch node with an “led” node using flip-flop-MEM to control led-LUM. Replace the clock node with a button node, and you have the circuit you are asking about.

3 Likes

as a circuit it worked like in video , but its just I didnt understand how it worked (the principal ) for the second case which is once on then once off with the same button…so it worked for me but I didnt understand how it works cause I didnt understand why the toggle in flip flop is used to make the led once on then once off with one button, in the info of the flip flop its said toggle converts the stored value, this means if the input (button) 1 makes output of flip flop (mem) 0 and if input(button) 0 makes output of flip flop (memory)1…but how could this work to make the output always 1 when press the button then always off when press the button again

1 Like

The flip-flop input pins only change the output when they are pulsed. If you feed a Boolean value to the pin, it only changes the output value when the input value changes from false to true (there is an implies pulse-on-true node to convert Boolean to pulse). This means if you connect a button to flip-flop-TGL, the flip-flop will toggle each time the button is pressed (changes to true). Holding the button keeps it true, releasing the button changes it to false, both of which are ignored by the flip-flop.

The “toggle changes 0 to 1 and 1 to 0” is in reference to the output, not the input. If the output is 1 when the TGL pin is pulsed, output will change to 0.

3 Likes

nice…thank you so much

Haha))) who needs buttons? (joke) The most useful function of a FLIP-FLOPS is being a trigger or flag (whatever you want). If you during a cycle need to avoid unpredictable switches, you have to use it.
I’ve just done a task only with help of it. Sensor reacted for a movement and pump switched on for a 4 sec. And believe me… there were so many wasted switches, that I could not even predict. Only flip-flop node could solve that issue. Before that I even wrote a pure code in IDE, because I was sure that task might be solved only manually.
This program XOD do not have a HELP or instruction for EVERY node. I’ve spend so much time for my creation, that it is unexceptionable.

1 Like

If you want to run a pump for 4 seconds every time a sensor is triggered, “delay” is probably the node you want to use rather than flip-flip. Unless you want time between triggers, you can tie the sensor output directly to delay-SET. delay-ACT can then be used to drive pump relay. I’m pretty sure the built in tutorial has an example just like this using button, delay, and led nodes.

If you don’t want the pump triggered again while it is running, or for a set time after each trigger, you can have delay-ACT trigger a second delay node for the time you want sensor disabled. This can be used to disable sensor if that is an option, or control a “gate” node between the sensor and delay node that runs the pump to block sensor output. Either way, you will probably need a “not” node to negate the output of the second delay node (you want sensor enabled when ACT is false).

1 Like