Question About Pneumatic Cylinder Control Project

If the assembly is stationary, you can use an accelerometer as a tilt sensor and I expect you'll be able to find examples doing that.

If it's moving I think you will need a gyro and accelerometer and some clever maths to combine them - for this solution I suggest you search for the algorithms used to control flying drones.