Best sensor for balancing inverted pendulum I want to build a balancer for an inverted pendulum. Which of the following sensors is best suited for detecting the tilt?


Accelerometer
Gyroscope
Angle sensor
As you say yourself, you want to detect the tilt of the pendulum rod, so I'm assuming what you're after is actually its angle. Measuring anything else would probably result in tedious calculations anyway; and in addition, considering you'll want to try to keep the angle in a specific range, you'll need to know it.

As such, an angle sensor may seems the most logical choice; but a gyroscopic sensor will not only offer you the angle, but some indication of the current rotation speed as well, which will be useful if you want to mimic the behaviour of a servomechanism.

However, these two sensors are single-axis only, which means that if you want the rod to be able to swing in more than one dimension, you'll have to use one sensor per axis, which may prove cumbersome to build. In that case, the acceleration sensor is probably better.

All in all, all 3 sensors are probably usable somehow, but it really depends on what exactly it is you want to build, and what you've tried so far. I'd also recommend searching for similar projects; for example, there are numerous NXT "segway" robots out there, and there's a detailed tutorial on how to build one with a gyroscopic sensor. Note that the feat seems to be possible even using a simple color sensor to detect ground proximity instead of knowing the exact angle.