Help with a project

As a hint, you'll need to keep track of the previous value, to compare to the current value. Perform the action only when the new and old values are not on the same side of 500.