Best Sensor to Track Rotation of Bike Handlebars?

Hi,

I am somewhat new to Arduino, sensors and electronics so I wanted to gather some ideas for sensor options for a project I am working on. I would like to be able to track direction of a bike by mounting some type of sensor onto the handlebars of a bicycle. What kind of sensor do you guys think would be most effective for tracking this data?

**** EDIT/MORE INFORMATION **** I would like the sensor to track the rotation, or angle, of the handlebars relative to the frame of the bicycle and output some values I can scale (likely between -180 to 180 degrees). If this is relevant at all, the bike itself would be made stationary allowing only for movement from the handlebars' rotation and for pedaling to spin the back wheel to track speed.

Have you looked into these - 3 Axiz gyro and accelerometer; they work well for my projects.

Do you mean direction relative to North? If so, you need a magnetometer configured as an electronic compass, or an absolute orientation sensor like the BNO055.

If it is to track the rotation of the handle bars as you wrote in the subject (I hope you realise you're pretty ambiguous in what you want!), relative to the frame, I'd be looking at a potentiometer kind of sensor, as it gives you an absolute analog signal telling you the angle it's at.

If it is a case of handlebar rotation in respect to the frame might I suggest this. A magnet and 2 hall sensors. You would have to calibrate degrees to output voltage. The reason for 2 sensors is to identify direction eg left or right. If a large degree of turning is done you will need extra hall sensors. The magnet would be attached to the steering stem the sensors to the frame. I would advise using an ADS 1115 AtoD converter as it is a lot more accurate than the Arduino onboard AtoD converter. Kendrick