Go Down

Topic: IR Remote controlled finger for camera shutter (completed with demo video) (Read 3649 times) previous topic - next topic

carl1864

This is one of my first completed arduino projects.  A IR remote controlled (and also laser controlled) finger to manually press a camera shutter button on a Nikon P100 camera, since that camera has no other way to support remote shutter.

Demo video here.  http://www.youtube.com/watch?v=FhRnf90AYJU

I plan to eventually put up some sort of tutorial somewhere for other newbies to help avoid some of the issues I struggled with while learning, if anyone knows a good place to put up a quick and simple tutorial without a bunch of hoops to jump through let me know.

carl1864

By the way, here is the code.

Code: [Select]
/* Note, first time run, with no values stored in EEPROM might be a bit buggy,
as soon as values are stored, will work fine */

#include <IRremote.h>
#include <Servo.h>
#include <EEPROM.h>
int RECV_PIN = 11;  //ir reciever hooked on pin 11 through 220ohm resistor
Servo myservo;   // create servo object to control a servo

int position1;   //servo position 1
int position2;   //servo position 2
int position3;   //servo position 3
int codeValue;   //the code from the remote
int current;     //keeps track of current servo position

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  position1 = EEPROM.read(1);    //default servo positon 1
  position2 = EEPROM.read(2);   //default servo position 2
  position3 = EEPROM.read(3);  //default servo position 3
  irrecv.enableIRIn(); // Start the receiver
  myservo.attach(9);  // attaches the servo on pin 9
  myservo.write(position1);   //start the servo out at position 1
  current = position1;
}

void loop() {
  if (irrecv.decode(&results)) {
    codeValue = results.value;
    switch (codeValue) {
    case 16753245:   
      myservo.write(position1);
      current = position1;
      break;
    case 16736925:   
      myservo.write(position2);
      current = position2;
      break;
    case 16769565:   
      myservo.write(position3);
      current = position3;
      break;
    case 16761405:
      ++current;                //moves servo 1 degrees
      if (current > 179) current = 179;  //this makes sure the current variable doesn't exceed the servo range
      myservo.write(current);
      break;
    case 16748655:
      --current;
      if (current < 0) current = 0;  //makes sure variable doesn't drop below 0
      myservo.write(current);
      break;
    case 16712445:
      current += 10;  //moves servo 10 degrees
      if (current > 179) current = 179;
      myservo.write(current);
      break;
    case 16754775:
      current -= 10;
      if (current < 0) current = 0;
      myservo.write(current);
      break;
    case 16720605:   
      myservo.write(179);  //moves servo all the way to 179
      current = 179;
      break;
    case 16769055:   
      myservo.write(0);
      current = 0;
      break;
    case 16738455:   
      position1 = current;  //stores current position as servo position 1
      EEPROM.write(1, position1);  //writes position 1 to eeprom address 1
      break;
    case 16750695:   
      position2 = current;  //stores current position as servo position 2
      EEPROM.write(2, position2);  //writes position 2 to eeprom address 2
      break;
    case 16756815:   
      position3 = current;  //stores current position as servo position 3
      EEPROM.write(3, position3);  //writes position 3 to eeprom  address 3
      break;
    case 16724175:    //this is for the laser sensor
      int sensorValue = analogRead(A0);     //cds photocell hooked to analog 0, has 10k pulldown resistor to ground
      while (sensorValue > 950) {              //value can be adjusted, 950 very sensitive for my conditions
        digitalWrite(13, HIGH);        //status light, led on means laser is armed
        sensorValue = analogRead(A0);    //reads sensor value again for the loop
      }
     
      myservo.write(position3);
      current = position3;
      digitalWrite(13, LOW);             //turns led off to indicate status that servo was activated.
      delay(1000);                        //delay just for good measure, holds servo for a second
      myservo.write(position1);          //moves servo back to position 1
      current = position1;
      break;
  }
irrecv.resume(); // Receive the next value
}
}

Terry King

Regards, Terry King  ..On the Red Sea at KAUST.edu.sa
terry@yourduino.com  LEARN! DO! (Arduino Boards, Sensors, Parts @ http://yourduino.com

Branhel

Im very new to arduino and was looking for some thing like your project to use with my sony nex-3. I made a "copy paste" of your code but when I try to send the code to my arduino it gives so many errors that I dont know were is the problem !?!?! can you help me?
Thanks.
Ps. the errors ar in the atached file.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy