Using the interpolated values while the timer is running

When interpolating between two values, the $value variable holds the current value of the timer. So, if the timer is interpolating between 0.0 and 1.0 (the default values) and has a duration of 5 seconds, then here is how the value should change:
time (seconds)$value
0.00.0
1.00.2
2.00.4
2.50.5
3.00.6
4.00.8
5.01.0

the changed event is triggered whenever the value changes, so it will constantly send messages while the timer is running.

// a timer that prints out its values as it counts
timer (duration(5.0),start,
	when(changed,print("timer value=$value")),
	when(back,print("timer is finished")),
	)
To use the timer to animate an object, just connect the changed event to one of the properties of the node you want to animate, passing $value as one of the parameters. Since $value is constantly changing, the timer will keep sending updated messages to the object and make it animate.

To make this work correctly, however, you have to give the timer two more messages: the startValue and endValue.
These are the values that the timer should interpolate between. By default, it interpolates between 0 and 1; but most of the time you want to send numbers in a different range. The specific range will depend on what property you're animating: color values range from 0 to 255, orientation ranges from 0 to 360 degrees on each axis, scale can be any value but cannot be 0, position can be any value, etc. For this example, we're going to make the hand rotate once, so the starting angle is 0 and the ending angle is 360.
time (seconds)$value
0.00.0
0.560.0
1.0120.0
1.5180.0
2.0240.0
2.5300.0
3.0360.0

// spinning

timer clock (duration(3.0),startValue(0),endValue(360),start,
		when(changed,clockhand.orientation(0 $value 0)))
		
object clockhand (file(clockhand.pfb),position(0 5 5),orientation(0 45 0))

You can make this timer loop, again using the back event to restart the timer whenever it gets to the end.

// looping
timer clock (duration(3.0),startValue(0),endValue(360),start,
		when(changed,clockhand.orientation(0 $value 0)),
		when(end,start)
		)
		
object clockhand (file(clockhand.pfb),position(0 5 5),orientation(0 45 0))

You can also make it oscillate, by making it change directions when it gets to the front or the back. This example will move the hand back and forth like a metronome:

// back and forth
timer clock (duration(3.0),startValue(-90),endValue(90),start,
		when(changed,clockhand.orientation(0 $value 0)),
		when(back,reverse),
		when(front,forward)
		)
		
object clockhand (file(clockhand.pfb),position(0 5 5),orientation(0 -90 0))

(c) Ben Chang