Like skimask said, you have the code in you explanation of the project.
Jerson gave an "untested" example to get you started.

Think about this:
Code:
Two VAR : read ADC first : write that value to VAR1 : start LOOP : read ADC :_
write ADC value to VAR2 : IF VAR2 > VAR1 THEN ? : Now make VAR1 = VAR2_
GOTO LOOP