3D ROBOT ARM WITH ARDUINO

I don't understand?

Why don't you build a linkage like in one of the two pictures you have posted?

The important feature is that 2 points on the arm you want to stay horizontal should be fixed to two points on the base. Then the arm will always stay in the same orientation relative to the base.

Get some pieces of Lego and experiment.

...R