You probably need a separate boolean variable to indicate which direction you are going ... just from an int you can't tell whether you should be adding or subtracting.
Or you could use sine on frame number or something like that, though that won't give exactly the same result (i.e. a sine wave vs. a triangle wave)