Make arduino know where up and down are

Hello! I'm trying to build a Gimbal for controlling my rocket's motor.... For the starting calibration, my arduino needs to know where is the precise down, because it has to point on the precise down (you don't say?). How can I do it? I already have an IMU with gyro, accelerometer and magnetometer... do I need another sensor? Please help me!!!

Won't the accelerometer give you the down vector (Z axis)?

As long as there's no other acceleration (like during launch or transport) the accellerometer will indeed give the direction of gravity.

Thanks

You realize that "down" for a rocket is always towards the tail when the motor is thrusting? Even if it flips completely over in flight.

Your project may not be totally lost. You can identify gravity before launch and carefully measure the drift of the gyros in the common IMU sensor. Then as soon as acceleration is detected you can stop measuring acceleration and proceed with the gyros alone. For a typical hobby rocket motor that thrusts for only a second or two, the accumulated error will probably be under one degree.

There are control systems for model planes that use a number of light sensors and work out that down is darker than up. That won’t be affected by accelerations of your rocket and might be worth a look.

4 phototransistors pointed out the sides make a really good horizon detector. The gimbal swings until the brightness is equal on each pair.