First experience with shift register: GOES WRONG

I guess it stops after 32.768 seconds:

t0=millis() ;

You should use unsigned long for t0, not int.