LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
Check out the dIMU sensor which provides both accelerometer and gyroscope for all three axises in one sensor. It doesn't have a nice casing though. – Sebastian Wahl Jul 31 '13 at 11:59
dIMU Inertial Motion Sensor link – Joubarc Aug 1 '13 at 7:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.