Here is the code for this project



#include <Servo.h>

Servo servo1;
int irPort = 0;

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("init");

  servo1.attach(10);
  servo1.write(90);
  pinMode(irPort, INPUT);


}


void loop() {


  int reading = analogRead(irPort);

  Serial.println(reading);

  if (reading > 500) {
    takePicture();
    Serial.println("SNAP!");

    delay(1000);
  }
  delay(500);
}

void takePicture() {

  servo1.write(102);
  delay(100);
  servo1.write(90);
}
JSN Boot template designed by JoomlaShine.com