Push-Button number to second of led light

Hello together,
i hope somebody can help me.
I would like to make a sketch thats follow this rules:
1x push - 1 second led
2x push - 2 seconds led
3x push - 3 seconds led
The User has 2 seconds for decide for 1 or 2 or 3 seconds light.

Now it works once…the counter resets but the gate not. So how can i “reset” the gate?

This is not really a good use-case for gate. Gate basically prevents changes downstream while it is disabled…it doesn’t “become nothing” or reset when it is disabled.

To keep your current code, the select node can have X# inputs hard-coded to 1, 2, 3. The equal nodes can be used to pulse the delay nodes directly.

A better solution is just to use count output to feed delay-T. If you want to be able to change to other times in the future, you can feed count to nth-input-IDX instead of feeding directly to delay-T.

Specific solution will depend on how you want to handle specifics. After 1st button press, do you wait 2 seconds for more button presses before turning on LED? What happens if button is pressed while LED is on after time has been specified?

Assuming you want to wait 2 seconds to turn on LED & ignore button while LED is on, that means button can only change count while count is zero OR 2 second delay timer is active. Only start the 2 second delay timer if count is zero. Once 2 second delay timer is done, we start led delay timer (using count as delay time). When led delay timer is done, we reset count to zero & restart the process.

Just noticed this allows count to go higher than 3. To prevent that, you can add “and count < 3” between the “or” node & defer so button is disabled once count hits 3.

1 Like

Wow! First: Thanks a lot.

I will try first the solution with the equal nodes as pulse.
After this i will try to check your ideas with the other nodes.
Im really new to XOD so i dont know all nodes ;-).

To your question how the “rules” are.
Yes it would be nice if the user has 2 seconds for this decision. Because this is only a part of a bigger sketch i am not really know how the behaivor should be if the button is pushed an the led is on.

I will learn the next days a lot from your post. :wink:

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