How to calculate exact angle to the moon? I am building some device as a gift for my girlfriend.

For this device to work, I need to be able to calculate the angle to which I should look towards (3D angle), in order to see the moon.

This angle is affected by (and maybe not only):


The time of year.
The hour.
The location on earth from which I look.


I'm sure there's some formula that approximates the angle.

I don't need an exact value, I can live with +-1 degree.
For a one-off calculation, the easiest solution would be to use planetarium software, such as stellarium.

For a programming solution, a python package such as pyephem is an efficient way to calculate the position of the moon at multiple times, in a way that can be imported into a spreadsheet.

The apparent motion of the moon is more complex than you might think.  The moon moves about 15 degrees per hour due to the rotation of the Earth. But on top of this fairly simple motion is the Moon's actual orbit around the Earth, which is elliptical (and so this motion is not even, the moon moves faster when it is close to the Earth) and the position and inclination of the orbit is perturbed by the Sun. The perturbations are fairly regular, and can be calculated, but these effects (rotation of the earth, the orbit of the moon, the eccentricity of the orbit, perturbation of orbit) combine to make the actual calculation more complex  than "a formula" that can fit easily in a spreadsheet, which is why a package like pyephem is recommended.