The basic formula for linear interpolation would be something like
InterpolatedValue = X*t + Y*(1-t)
Y are the values to be interpolated between and
t is a parameter between
1 determining the degree of interpolation;
Y. Furthermore, you would like to have some periodic movement with a period length of
5, alternating the direction of interpolation; this can be achieved as follows. If
t is a nonnegative number growing over time, calculate
t' = t - t / 10
to remove all previous periods which have occured and
t'' = t' : t' in [0,5) 5 - t' : t' in [5,10)
and afterwards set
t''' = t' / 5
to normalize the parameter into
[0,1] and use the basic interpolation formula from the beginning.
Note that linear interpolation and various other methods are collected here.