Angle sensor for the bicycle handlebar?

Arduino needs to know, how many degrees or radians to the left or to the right the handlebar is compared to the body of the bicycle.
What would be an easy to use and install sensor? A range of +-30 degrees would be enough and the resolution could be e.g. 256 values for that range, or analog value. (Calibration could be done programmatically.)

Would a gyroscope be a good solution? (drift of the 0-point, "straight ahead"?)

One could use a potentiometer and read its value with AD-converter. But I suspect that any potentiometer would wear out soon in the constat motion of the handlebar.

Alternatives?

My first try would be a potmeter just to get feeling how good it works.
normally a pot == 270° so 30° is 1/9 implying an analog range of 1/9 of 1023 ~~ 110 values. Given you have 1 bit noise brings this down to 55 values.

That is too little, but by setting the AnalogReference() of the ADC to 1.1V (INTERNAL) you will get 55 * 5 /1.1 is approx 250 (500) distinct values .
See - analogReference() - Arduino Reference -

Alternatives?

An absolute rotary shaft encoder, optical or magnetic like this one:-
http://uk.farnell.com/austriamicrosystems/as5040-assu/encoder-magnetic-rotary-10bit-16ssop/dp/1630800

Grumpy_Mike:

Alternatives?

An absolute rotary shaft encoder, optical or magnetic like this one:-
http://uk.farnell.com/austriamicrosystems/as5040-assu/encoder-magnetic-rotary-10bit-16ssop/dp/1630800

What an interesting sensor! I've never seen one of these before.

More alternatives!

Here are some interesting applications as well: http://www.edn.com/article/470153-Speed_acquisition_made_simple.php or iC-Haus Homepage - Applications: Application Notes Magnetic Sensors .