STOPPING A SERVO

sarahisml:
this is the code for the PIR alone that is working

Your two programs are very similar. However you have a large number of tiny (and irrelevant) differences like extra blank lines and braces on different lines, or in different places on the line which made it very difficult to compare the two codes side by side.

You still have no code in the programs to print the values from the variable val. If the problem is caused by the current draw from the servo preventing the other things working that would be very obvious if you were monitoring the value of the variable.

It is also wise to put a Serial.println() statement into setup() so you can see if the program is continually re-starting. that current draw by the servo can also cause that.

And, even though I asked twice, you have not yet described the errant servo movement in detail. If you had (or do) it might immediately point to the behaviour one would expect if the Arduino is resetting.

...R