# A timed switch with Dynamic

I'm trying to make a binary switch that switches after a fixed given interval. Why doesn't the following work:

step = .1;
t = Dynamic[Clock[{0, 5, step}, 5, 1] ];
Dynamic[t >=  2]

-
Could someone with at least 300 points of reputation please add some more tags? –  zab Apr 28 '14 at 12:57
Dynamic[Clock[] > .5] –  Vitaliy Kaurov Apr 28 '14 at 13:10

Note that you've defined t as a Dynamic expression. A relational operator like GreaterEqual (>=) works with numeric expressions like the result of Clock. You could try something like this to get a displayed output that eventually switches from False to True:

step = .1;
Dynamic[{t, t = Clock[{0., 5., step}, 5., 1]; t >= 2}]

-
Thanks so much! –  zab Apr 28 '14 at 13:18

I couldn't help thinking about this question even after I voted for billsphere's perfectly satisfactory answer. Finally, I concluded that Trigger would be a better way to implement the requested functionality. It is just as easy to use as Clock and throws in a nice little control panel as a bonus.

With[{dt = 1, tmax = 10, threshold = 4},
Column[{
Dynamic @ Row[{t, " > ", threshold, " is ", t > threshold}],
Trigger[Dynamic @ t, {0, tmax, dt}, dt]}]]


-
@ m_goldberg, nope, Trigger doesn't work on the Linux version :-( –  zab May 2 '14 at 2:36