Thanks for the reply.
I received my Arduino a couple of weeks ago and meanwhile I ordered some other hardware - a couple of servos, motors, IR sensor, temperature sensor and some electronic components to make it all work.
Since I am very new at electronics and embedded systems, I tried some things out.
The reason that I attach/detach the servos is because I saw some irregular movements while testing the servos in another sketch. I am not sure where this movements came from. Attaching the servos when I needed them and detaching when the board did other things seemed to solve the problem. From my point of view, it also looked more logical to act this way. I will retry the code with a single attach at setup.
The delay after the attach was added after I saw both servos moving irregularly. Once the delay was added, both servos acted simultaneously, performing the same action synchronously, as they were programmed to do.
This sketch is a first try to find out how to program some interaction between the environment (via the IR sensor) and the hardware.
I wanted to find out how the servos would react if other tasks were executed between servo actions. Also how to program the hardware without any HW interrupts.
The current hardware configuration has no real purpose excepts finding out if it works at it should.
I was also looking for some programming style (naming pins, hardware and variables) and adding a reasonable amount of comment.
These are also my first steps in C-programming, although I have quite some experience in programming in other languages.
I am not at all sure that this sketch is written as it should be - e.g. repetition of action on the servos, delay time ...