Use this line when you press the 'unpause' key:
time=MilliSecs()-periodIf you're using this in a function, then 'time' and 'period' will need to be global.