Help with motion activated servo please.

Thanks guys! I tried again using all of the information you have all given, and I think I'm finally getting somewhere. :slight_smile:

There are just a couple of minor issues that I'd like to check with you please:
-When I run my hand past the sensor, it usually takes a few attempts before the servo moves. Is this just an issue with the integrity of the PIR rather than the coding?
-When it is in its resting state, the servo buzzes continuously (not loud though), is this normal?

Here is the code:

#include <Servo.h>

 int pos = 0;
 int PIR = 7;
 Servo myservo;

 void setup () {
 pinMode(PIR, INPUT);
 myservo.attach(11);
 }

 void loop (){
 myservo.write(pos);
  if (digitalRead(PIR) == HIGH) {
    myservo.write(300);
    delay(2000);
 }
if (digitalRead(PIR) == LOW) {
    myservo.write(0);
    delay(2000);
 }
 }

Other than that, it's working as I had hoped :slight_smile: