How many steps did I walk?
CJam, 27 24 bytes

l~:Xfe&lt;0fe&gt;_[XT]:Y--Y/,(


Input format is the list of pendulum positions followed by l on a single line.

Test it here.

Explanation

l~     e# Read and evaluate input.
:X     e# Store track length in X.
fe&lt;    e# Clamp each position to X from above.
0f&gt;    e# Clamp each position to 0 from below.
_      e# Duplicate.
[XT]   e# Push the array [X 0].
:Y     e# Store it in Y.
-      e# Set subtraction from the clamped input list. This gives all the
       e# intermediate values.
-      e# Another set subtraction. Remove intermediate values from input list.
Y/     e# Split remaining list around occurrences of ...X 0...
,(     e# Count them and decrement. This is the number of times the pendulum
       e# moved from X to 0.